August 30 2012

HTML5 elements in old Internet Explorer

I came across this issue while noticing a < header > element was being rendered in IE8 as a block element. After a quick search, I found this page which gives a quick and clean solution.

Basically, the idea is to create through javascript the HTML5 elements, give them block positioning and finally top all this with a conditional < !--[if lt IE 9] >.
I implemented their final piece of code:

[sourcecode language="html"]
< !-- Pulled from http://code.google.com/p/html5shiv/ -->
< !--[if lt IE 9]>
< script src="//html5shim.googlecode.com/svn/trunk/html5.js">
< ![endif]-->

[/sourcecode]

and it worked like a charm!