To allow IE (IE6/IE7/IE8) to support HTML5 elements, we need to add the following JavaScript to the HTML header, which is a simple document.createelement declaration, using conditional annotations for IE to invoke this JS file. Opera,firefox and other non-IE browsers will ignore this code, and there will be no HTTP requests.
Way one: Refer to Google's html5.js file, the code can download the content of their own to see.
| The code is as follows |
Copy Code |
<!–[if LT ie9]> <script src= "Http://html5shiv.googlecode.com/svn/trunk/html5.js" ></script> <! [endif]–> |
Put the above code in the head tag range
Mode two: oneself coding js to fix.
| The code is as follows |
Copy Code |
<script> (function () { if (! 0) return; var e = "abbr, article, aside, audio, canvas, DataList, Details, dialog, EventSource, figure, Footer, header, Hgroup, Mark , menu, meter, nav, output, progress, section, time, video. Split (', '); var i= e.length;//www.111cn.net while (i--) { Document.createelement (E[i]) } })() </script> |
Whichever way you use it, remember to define the following in CSS to make these tags a block element, just like Div.
| The code is as follows |
Copy Code |
/*html5*/ Article,aside,dialog,footer,header,section,footer,nav,figure,menu{display:block} |
Since it was addressed to IE, I have modified the contents of the header condition annotation
| The code is as follows |
Copy Code |
<!--[If Lt IE 9]> <script src= "Html5.js" ></script> <style> Article,aside,dialog,footer,header,section,footer,nav,figure,menu{display:block} </style> <! [endif]--> |
In this way, IE will be able to normally display the HTML5 tags written things, such as
| code is as follows |
copy code |
| <nav <a href= "" >home</a> <a href= "" >previous</a> <a href= "" >Next</a> </nav> |