Check out my latest project: Full Frontal JavaScript Conference

HTML5 enabling script

Since HTML5 is getting more attention by way of marking up our new pages, and the only way to get IE to acknowledge the new elements, such as <article>, is to use the HTML5 shiv, I've quickly put together a mini script that enables all the new elements.

Usage & Download

The html5.js and must be inserted in the head element (this is because IE needs to know about the element before it comes to render them - so it can't sit in the footer of the page, i.e. below the elements in question).

I've now moved HTML5 shiv to be hosted on a Google code project with the correct mime type being served, so if you're happy with the extra HTTP request, you can hot link the script: http://html5shim.googlecode.com/svn/trunk/html5.js

It's conditional within the code, so Firefox et al won't run the code - but it doesn't hurt to wrap it in an IE conditional call to reduce the http pulls for other browsers:

<!--[if IE]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

I've also minified the file, so it's a matter of bytes to download.

88 Responses to “HTML5 enabling script”

  1. Thanks for an excellent script. I've tried it with Mads Kjaer's HTML5/CSS3 example from here
    http://net.tutsplus.com/tutorials/html-css-techniques/html-5-and-css-3-the-techniques-youll-soon-be-using/

    A couple of items of feedback:
    1) Is CSS3 "z-index" usable? It seems to be ignored.
    2) CSS3 "section" works well, is it possible to use "aside"?

    Thanks!

  2. [if IE lt 9] ?

    Well I suppose we should wait on that until IE9 final is out. But at some point...

  3. Thanks for this handy script. I should now make my hands dirty with HTML5 and IE

  4. You seem to have a duplicate project under a similar name ?
    Whats the difference between html5shim and html5shiv ?

  5. Mauricio Vargas June 28th, 2010 at 12:59 am

    I've tested the HTML5 in IE9 (preview till now) and it worked sooo great, that will be such a relief to us, developers, if IE9 comes out and Microsoft make an effort to "lt IE9" users change and update, maybe providing some example pages and some free stuff...

  6. Wow, I am currently in the process of compleatly recoding my site in HTML5 and this is going to save my skin a few times I beleive. I am aiming for an almost no image site so it is pure un-adulterated HTML5. Bless its little markup.

  7. If I understand the purpose of this code correctly, it shouldn't be needed with IE9. IE9 supports the concept of generic elements, which are elements that IE that doesn't recognise but renders (and applies CSS too) anyway.

    If it does anymore than John Resig describes in the attached post, it may still be necessary for IE9 and above.

    This is an excellent script that has allowed me to start writing semantic mark-up, very grateful.

    Rich

  8. I was wondering if the code is already designed to ignore/'be ignored by' IE9? If not how would I set it up so that IE9 and above ignores it?

Leave a Reply
Not required

CODE: Please escape code and wrap in <pre><code>, doing so will automatically syntax highlight