Latest web development tutorials

HTML5 Browser Support

You can let some older browsers (does not support HTML5) support for HTML5.

HTML5 Browser Support

Modern browsers support HTML5.

In addition, all browsers, including old and new, of the unrecognized element will be automatically processed as an inline element.

Because of this, you can"church" browsers handle "unknown"HTML elements.

Note You can even church IE6 (Windows XP 2001) browser handles unknown HTML elements.

The HTML5 element is defined as a block element

HTML5 set of eight new HTML semantics (semantic) elements. All of these elements are block-level elements.

In order to allow older versions of the browser to display these elements correctly, you can set the CSS display property value block:


header, section, footer, aside, nav, main, article, figure { display: block ;}

Adding a new element to HTML

You can add new elements to HTML.

Examples of the new elements added to HTML, and style elements defined for the element called <myHero>:


<! DOCTYPE html> <Html> <Head> <Meta charset = "utf-8"> <Title> HTML to add a new element </ title> <Script>
document. createElement ( "myHero")
</ Script> <Style>
myHero { display: block ; Background-color: #ddd ; Padding: 50 px ; Font-size: 30 px ;}
</ Style> </ Head> <Body> <H1> My first title </ h1> <P> My first paragraph. </ P> <MyHero> My first new element </ myHero> </ Body> </ Html>

try it"

JavaScript statement document.createElement ( "myHero") is to add a new element to the IE browser.

Internet Explorer browser issues

You can use the above method to add HTML5 elements IE browsers, but:

Note Internet Explorer 8 and earlier versions of IE browser does not support more than one way.

We can use Sjoerd Visscher created "HTML5 Enabling JavaScript", "shiv " to resolve the problem:

<-! [If lt IE 9]>
<Script src = ""> </ script>
<! [Endif] ->

The above code is a comment, the role when the IE browser version less than IE9 will read html5.js file and parse it.

Note: Please domestic users use the site static repository (Google repository instability in the country):

<-! [If lt IE 9]>
<Script src = ""> </ script>
<! [Endif] ->

For IE browser html5shiv is a better solution. html5shiv main solution proposed new HTML5 elements IE6-8 not recognize these new elements can not be wrapped as a parent node child elements, and can not apply CSS styles.

Shiv perfect solution


<! DOCTYPE html>
<Meta charset = "utf-8">
<Title> Render HTML5 </ title>
<-! [If lt IE 9]>
<Script src = ""> </ script>
<! [Endif] ->
</ Head>


<H1> My first article </ h1>

This tutorial - science is not only technology, but also a dream! ! !
</ Article>

</ Body>
</ Html>

try it"

html5shiv.js reference code must be placed in <head> element, because the IE browser when parsing HTML5 new elements need to load the file.