HTML5 tags are not compatible (IE6 ~ 8), html5ie6
The Semantic tags and attributes of HTML5 make it easy for developers to easily achieve a clear web page layout. With the help of CSS 3 rendering, it is very easy to quickly build a rich and flexible web page.
The new tag elements of commonly used HTML5 products include:
- <Header> define the header of a page or segment;
- <Nav> define the navigation area of a page or segment;
- <Section> logical area or content combination of the page;
- <Article> define the body or a complete content;
- <Aside> define supplementary or related content;
- <Footer> defines the end of a page or segment;
Using them can make code semantics more intuitive and more convenient for SEO optimization. However, this HTML5 new tag cannot be identified on IE6, IE7, or IE8 and needs JavaScript processing.
Method 1: Create elements using JavascriptDocument. createElenment ("......")
Add the following code to
1 <!--[if lt IE 9]>2 <script type="text/javascript">3 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(', ');4 var i= e.length;5 while (i--){6 document.createElement(e[i])7 } 8 </script>9 <![endif]-->
Method 2:Use Google's html5shiv package (recommended)
1 <!--[if lt IE 9]> 2 <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>3 <![endif]-->
However, no matter which method is used, the CSS of the new tag must be initialized. because HTML5 is represented by inline elements by default, we need to use CSS to manually convert these elements into block elements for easy layout.
1 /*html5*/2 article,aside,dialog,footer,header,section,footer,nav,figure,menu{display:block}
However, if ie6/7/8 disables the script, it will become a "whiteboard" webpage without style. How can we solve this problem?
We can refer to facebook's practice to guide users into the noscript-marked"/? _ Fb_noscript = 1"Page, use html4 tags to replace html5 tags, Which is lighter than writing a large number of hack to maintain compatibility.
1 <! -- [If lte IE 8]> 2 <noscript> 3 <style>. html5-wrappers {display: none! Important ;}</style> 4 <div class = "ie-noscript-warning"> your browser has disabled the script, please <a href = ""> check here </a> to enable the script! Or <a href = "/? Noscript = 1 "> continue access </a>. 5 </div> 6 </noscript> 7 <! [Endif] -->