HTML5 hack for less than IE8

Internet Explorer 8 and earlier can’t hack HTML 5 elements. To fix it:

Include this line of code in your head. We want it to load before any other scripts.

<!--[if lt IE 9]><script type="text/javascript" src="js/html5.js"></script><![endif]-->

Here is the content of html5.js

document.createElement("article");
document.createElement("aside");
document.createElement("audio");
document.createElement("canvas");
document.createElement("command");
document.createElement("datalist");
document.createElement("details");
document.createElement("embed");
document.createElement("figcaption");
document.createElement("figure");
document.createElement("footer");
document.createElement("header");
document.createElement("hgroup");
document.createElement("keygen");
document.createElement("mark");
document.createElement("meter");
document.createElement("nav");
document.createElement("output");
document.createElement("progress");
document.createElement("rp");
document.createElement("rt");
document.createElement("ruby");
document.createElement("section");
document.createElement("source");
document.createElement("summary");
document.createElement("time");
document.createElement("video");

Update 27, March 2011

Or, like Danny van Kooten said “An easier way is to use the HTML 5 shiv that’s hosted on googlecode by Remy Sharp”:

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

One Reply to “HTML5 hack for less than IE8”

Comments are closed.