HTML 5 and Internet Explorer 7 and 8

HTML 5 is not implemented by Internet Explorer, but it is possible that the browser recognizes the new tags from that format, and it is the blog of the WHATWG, creator of the format, which explains how.

Note that this trick will be completely obsolete once Google Chrome Frame, currently in alpha stage, will be finalized.

The unveiled trick is being turned into a the script on to HTML 5 tags recognized by Internet Explorer either in version 6, 7 or 8.

This script is compact and so it is not very easy to read, so I made a readable version, to let understanding how it works:

    if(!/*@cc_on!@*/0)return;   // conditional compilation  
var str = "abbr,article',aside,audio,bb,canvas,datagrid,datalist,details,dialog, eventsource,figure, footer,header,mark,menu,meter,nav, output,progress,section,time,video"; var list = str.split(","); for(i = 0; i < list.length; i++) { document.createElement(list[i])
} } )

We see that the new tags are created at the global level in the page, it is a trick which allows the DOM engine of Internet Explorer to identify them when they are present in the body of the page!

Of course the execution of the script may be restricted to the Internet Explorer browser only:

<!--[if IE]>
    <link rel="stylesheet" href="html5.js">

This trick applies to the new tags, but HTML 5 is more than that, it is also Canvas, storage, multimedia tags ...
But there are also plugins to add the Canvas tag to IE, and support for its content.

The usefulness is mainly to apply styles to page elements defined with the new tags and to have a compatibility with all browsers.

The same technique est used by another project, HTML 5 Shiv.
Once an element is created and added to the DOM, a style is applied to it, and this style is recognized each time this element is used in the page.

See also ...

© 2009-2012