HTML5 & Internet Explorer

Once again, Internet Explorer causes problems. This time with the adoption of HTML5.

HTML5 is ready to use today. There is very little stopping you from using HTML5 for all new websites you code. All except for one small problem: Internet Explorer needs a kick up the butt to render your code properly. It needs something called the HTML5 javascript shiv.

Internet Explorer, in its infinite wisdom, does not allow you to style an element that it does not recognise. This is not very future-proof, and causes problems as HTML5 adds a lot of new elements. The only way to get around this is to use javascript to force Internet Explorer to recognise the new elements. Basically, the code looks like this:


This is repeated for all the new elements, inserted into a browser-sniffing conditional and minified for your downloading convenience. Fixed!

Of course, there will be those without javascript enabled, and the best we can do for them is this:

<!--[if IE]>
<p>You need to enable javascript
in your browser to view this website.</p>

Is this useful for the viewer? No, they probably do not know what javascript is, or whether this message can be trusted—and they should not be expected to. But it is necessary. Will this be fixed in future versions of Internet Explorer? I certainly hope so, but then it will be decades before everybody has switched to that new version – just take a look at how many people are still using Internet Explorer 6.

There has never been more reason to dump Internet Explorer and get one of the better, free alternatives: