HTML5 browser support, HTML5 Browser
You can make some earlier browsers (not HTML5 supported) Support HTML5.
HTML5 browser support
Modern browsers support HTML5.
In addition, all browsers, including the old and the latest, automatically process unrecognized elements as inline elements.
Because of this, you can"Church"Browser Processing"Unknown".
|
You can even teach IE6 (Windows XP 2001) browsers to process unknown HTML elements. |
Define HTML5 elements as block elements
HTML5 has set 8 new HTMLSemantics (semantic)Element. All these elements areBlock levelElement.
You can setDisplayThe property value isBlock:
Instance
Header, section, footer, aside, nav, main, article, figure {
Display: block;
}
Add new elements to HTML
You can add new elements to HTML.
This instance adds a new element to HTML and defines a style for this element. The element name is<MyHero>:
Instance
<! DOCTYPE html>
<Html>
<Head>
<Title> Creating an HTML Element </title>
<Script> document. createElement ("myHero") </script>
<Style>
MyHero {
Display: block;
Background-color: # ddd;
Padding: 50px;
Font-size: 30px;
}
</Style>
</Head>
<Body>
<H1> my first title
<P> my first paragraph. </P>
<MyHero> my first new element </myHero>
</Body>
</Html>
Java/"style =" color: rgb (51, 51, 51); text-decoration: none; "target =" _ blank "> JavaScript statementDocument. createElement ("myHero ")To add new elements to the IE browser.
Internet Explorer Problems
You can use the above method to add HTML5 elements to the IE browser,:
|
Internet Explorer 8 and earlier IE versions do not support the above methods. |
Fortunately, Sjoerd Visscher created "HTML5 Enabling JavaScript ","Shiv":
<Script src = "https://html5shiv.googlecode.com/svn/trunk/html5.js"> </script>
<! [Endif] -->
The above code is a comment, which is used to read the html5.js file and parse it when the IE browser version is earlier than IE9.
Note:Domestic users should use Baidu static resource library (Google resource library is unstable in China ):
<! -- [If lt IE 9]>
<Script src = "https://apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"> </script>
<! [Endif] -->
Html5shiv is a good solution for IE browsers. Html5shiv mainly solves the problem that the new elements proposed by HTML5 are not recognized by the IE6-8. These new elements cannot wrap child elements as parent nodes, and they cannot apply CSS styles.
Perfect Shiv Solution
Instance
<! DOCTYPE html>
<Html>
<Head>
<Title> Styling HTML5 </title>
<! -- [If lt IE 9]>
<Script src = "https://apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"> </script>
<! [Endif] -->
</Head>
<Body>
<H1> my first article
<Article>
London is the capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.
</Article>
</Body>
</Html>
Html5shiv. js reference code must be placed in the