How does the html5 browser support HTML5 label styles for all browsers?

Source: Internet
Author: User

Comments: Now HTML5 is attracting more and more attention. HTML5 developers will have to consider the question of backward compatibility: how to make all browsers recognize HTML5 tag styles is attracting more and more attention, currently, HTML5 browsers are not mainstream, especially IE6 is still used for nearly 50% of domestic users. Because IE9 that supports HTML5 does not support Windows XP system installation, this will take a long time to come, HTML5 developers will have to consider the problem of backward compatibility. There are many HTML5 labels or CSS selector compatibility practices. One of them is to generate a tag element.
For the basic principle, see the following code in IE8. The style does not work at all.

The Code is as follows:
<Html>
<Head>
<Style> mxria {color: red ;}</style>
</Head>
<Body>
<Mxria> Hello! </Mxria>
</Body>
</Html>


To identify the <mxria> </mxria> label and display the effect of the corresponding style in the browser, we can add a section of js below, and the effect will be different.

The Code is as follows:
<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 secrets! Yes, it is document. createElement, HTML5 shiv is such a js plug-in that all HTML5 labels are regenerated. You need to load the plug-in, then the HTML5 program can be recognized by all browsers.

Related Article

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.