Ways to allow IE6/7/8 to support HTML5 tags

Source: Internet
Author: User

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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.