Datetime in habari

Right now I am reading the most excellent book by the esteemed Bruce Lawson and his partner in crime Remy Sharp. I must say, to start with, that is a great read, which has me whipping out my laptop. Even on a sunday morning, before my 2nd breakfast, which is really uncommon. I even started to hack away at this site, just for the heck of it...

And that is the small thing that I wanted to share with you. I don't know why but I haven't gotten around to properly adding the time attribute to this site, even though I got it in #html5 for quite some time now. Somehow it didn't happen, but anyway, here is the code to add it in habari.

<time 
datetime="<?php echo $post->pubdate->text_format('{Y}-{m}-{d}'); ?>"
pubtime>
<?php echo $post->pubdate->
text_format('<span>{M}</span>
<span>{d}</span>,
<span>{Y}</span>');
?>
</time>

It's just a small bit, but I hope it is of help to someone who uses habari...

It's visible content is in dutch / european order, but I'm sure you can change that to suit yours...

HTML5 safe usage 3

Oct 19, 2010 0 Comments
Tagged: , and

As you may recal, I wrote a small piece on #html5 input types a while go here, in which I stated:

If you use an unsupported input type in a browser it falls back to text, what I didn't knew is that reading the type with JavaScript fails also. CSS attribute selectors are fine, only no JavaScript detection.

As it turns out, I was mistaken. It is quite possible to detect the type of the input elements, all it takes is the reading of the type attribute, like this:

$('input').each(function(){
var tt = this.getAttribute('type');
if(!tt)tt='text';
this.className +=' input-'+tt;
});

And voila, we have got a class on the element, with which we can style it or hook some javascript onto it...

Article in html5

Sep 28, 2010 0 Comments
Tagged:

bruce_lawson

"An analogy I like was given to me too late to make the book. Think of <article> not in terms of print, like 'newspaper article' but as a discrete entity like 'article of clothing' that is complete in itself, but can also mix with other articles to make a wider ensemble."

(Via Bruce Lawson)

HTML5 safe usage 2

Sep 08, 2010 0 Comments
Tagged: and

Input elements

Input elements are interesting enough for a much longer and more extensive post than I have time for now, but here is one little tidbit I haven't read anywhere else. If you use an unsupported input type in a browser it falls back to text, what I didn't knew is that reading the type with JavaScript fails also Turns out, I was wrong, see here who to detect it.... CSS attribute selectors are fine, only no JavaScript detection. See for yourself below...

Go and compare it with different browsers, just to see which does what.

HTML5 safe usage 1

Sep 08, 2010 0 Comments
Tagged: and

This is the first in a serie of posts about html5, sharing the various things I learned the last few weeks.

The last few weeks I have been doing quit some research on html5 and the various new input types. All this out of sheer curiosity and for a presentation I held just yesterday at iprofs for Fronteers. I started with the full intention of holding a enthusiastic speech on how wonderful everything was and that the future is now.

Sadly my story was not so positive as I had hoped, although I hope that I didn't scare people away from html5, as I truly believe that is something you can use now. Maybe only a sub set if your audience still uses IE6 and you don't want to be dependent on javascript. Let me just show you some ways to savely use html5 now.

Layout elements

Older browsers don't support the new layout elements and are not able to style them, you could use javascript to help them. Or you could fake the semantics by using classes and div's. So instead of using :

<article>Some content</article>

You could use:

<div class="article">Some content</div>

And have your cake and eat it too, as in: Support older browsers and use the proper semantics that html5 bring you. You could use this same technique for the various other html5 layout elements.

And maybe there comes a time that everybody supports html5 and you can than search and replace the various elements and finally be one of the cool kids.