HTML5Shiv perfectly solves the problem that IE (IE6/IE7/IE8) is not compatible with HTML5 labels _ javascript skills

Source: Internet
Author: User
This article mainly introduces how HTML5Shiv perfectly solves the problem that IE (IE6IE7IE8) is not compatible with HTML5 labels. if you need it, you can refer to the semantic tags and attributes of HTML5, developers can easily achieve a clear web page layout, and add CSS 3 rendering effects to quickly build a rich and flexible web page.

HTML5 new tag elements include:

Define the header of a page or segment;
Define the end of a page or segment;
Define the navigation area of a page or segment;
Logical area or content combination of the page;
Define the body or a complete content;
Define supplementary or related content;




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. The following describes several methods.
Method 1: Coding JavaScript

     

For IE browsers under IE9, HTML5 tags will be created, so that non-IE browsers will ignore this code and there will be no unnecessary http requests.

Method 2: Use Google's html5shiv package (recommended)

     

Because google's server access card in China is used, it is recommended to call cdn in China.

     

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.

The code is as follows:


/* Html5 */
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 "/? _ Fb_noscript = 1 "page, use html4 tags to replace html5 tags, which is lighter than writing a large number of hack to maintain compatibility.

     

In this way, the user can be guided to open the script or directly jump to the HTML 4 tag design interface.

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.