Comment: More and more sites are starting to use HTML5 tags. But the current situation is that there are still many people using IE6, IE7, and IE8. Here is a method to enable ie browser to support html5. Friends who need it can refer to it.
Nowadays, HTML5 is attracting more and more attention, but currently browsers that support HTML5 are not mainstream, especially more than 50% of domestic users still use IE6. Since IE9, which supports HTML5, does not support Xp system installation, HTML5 developers will have to consider the issue of backward compatibility for a long time in the future. There are many ways to use HTML5 tags or CSS selector compatibility, and one is one of them to generate tag elements.
For basic principles, see the following code for the effect in IE8, the style does not work at all.
<html>
<head>
<style>mxria{ color: red; }</style>
</head>
<body>
<mxria>Hello!</mxria>
</body>
</html>
In order for the browser to recognize the <mxria></mxria> tag and display the effect of the corresponding style, we can add a section of js as follows, and the effect will be different when you see it.
<html>
<head>
<style> mxria{ color: red; }</style>
<script>document.createElement("mxria")</script>
</head>
<body>
<mxria>Hello!mxria.com</mxria>
</body>
</html>
Now everyone understands the mystery! Yes, it is document.createElement. HTML5 shiv is such a js plugin that regenerates all HTML5 tags. You need to load the plugin, and then the HTML5 program can be recognized by all browsers.
Download address:
Simple usage of trunk/html5.js:
Here is the html5.js file that references Google:
The use of html5shiv is very simple. Considering that IE9 supports html5, you only need to add the following code to the page head:
<!--[if lt IE 9]>
<script src="dist/html5shiv.js"></script>
<![endif]-->
Copy the above code to the head part, remember to be the head part (because IE must know this element before element parsing, so this js file cannot be called in other locations, otherwise it will be invalid)
Of course, you can also take out the code and do it yourself:
(function(){if(!/*@cc_on!@*/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(','),i=e.length;while(i--){document.createElement(e[i])}})()
Finally, add this paragraph to the css:
/*html5*/ article,aside,dialog,footer,header,section,footer,nav,figure,menu{display:block}
Mainly, let these html5 tags be blocked, like div.
OK, let's just briefly, in one sentence, it is: quote html5.js to make the html5 tag into blocks