Hi, I’m Nico Hagenburger
I enjoy designing
clean, simple websites,
developing living style guides
& increasing usability.

A Simple HTML5 Fix for IE

Internet Explorer up to version 8.0 (it is fixed in 9.0) can’t read HTML5 tags properly. In recent projects I used modernizr to fix this. But since I don’t need all the features modernizr provides all the time, this is an expensive (slow) extra HTTP call in the header which prevents the content from beeing loaded.

I wrote a simple solution which works well in Internet Explorer 6.0/7.0/8.0 (have a look at the IE test page).

  for(var e,l='article aside footer header nav section time'.split(' ');e=l.pop();document.createElement(e))

Do you have any shorter piece of code? I love to hear from you.

(You could more more HTML5 element types. My typical list is: article aside figcaption figure footer header hgroup nav section time)

Update: A Shorter Version is Possible (February 16th, 2011)

Paul Irish sent me an even shorter version:

  'article aside footer header nav section time'.replace(/\w+/g,function(n){document.createElement(n)})

(Thanks to remy, porneL, jdalton, community.)