IE fix for HTML 5 elements

HTML 5 is far from finished (for those of you that want to know how many days are left till the official release date: check, make sure that you check out the source code of the page too) and not all major (or less major) browsers support the new semantic elements yet. Internet Explorer for example has some problems seeing and thus styling the elements, resulting in a messed up layout. Luckily, there is an easy fix for this.

cdl_capture_2011-06-22-39_ 000


IE fix for HTML 5 elements

Because IE 8 and lower does not see the elements it cannot style the elements. Resolving this issue is easy, just create the elements using JavaScript. When you do this before the page is rendered, in the head section of your webpage, IE will have no problem styling our newly created elements. This is called the “HTML 5 shiv”

You can just use the usual JavaScript function createElement() to create the elements you’ve used, this goes as followed:

document.createElement("header"); //repeat for all used "new" elements

That’s one way to do it. An easier way is to use the HTML 5 shiv that’s hosted on googlecode by Remy Sharp. I’m using it myself too. It’s minified and wrapped in conditional tags so it’s only a few bytes that have to be downloaded by browsers like IE 8 and below to be able to render the “new” elements. Just add the following script tags to your head section and all browsers should be fine rendering the “new” HTML 5 elements.

<!--[if IE]>
	<script src=""></script>

The JS script uses conditionals itself too so if you leave out the if IE conditionals the script will still not be ran by FireFox 3+ or Webkit browsers. Happy HTML 5 theming!


  3. demo {}

Why use Modernizr?

Taking advantage of the new capabilities of HTML5 and CSS3 can mean sacrificing control over the experience in older browsers. Modernizr 2 is your starting point for making the best websites and applications that work exactly right no matter what browser or device your visitors use.


IE7.js is a JavaScript library to make Microsoft Internet Explorer behave like a standards-compliant browser. It fixes many HTML and CSS issues and makes transparent PNG work correctly under IE5 and IE6.

Leave a comment