HTML5 Browser support

You can make some older browsers (that don’t support HTML5) support HTML5.


HTML5 browser support

Modern browsers support HTML5.

Also, all browsers, old and new, automatically handle unrecognized elements as inline elements.

Because of this, you can “teach” the browser to handle “unknown” HTML elements.

You can even teach the IE6 (Windows XP 2001) browser to handle unknown HTML elements.


Define HTML5 elements as block elements

HTML5 defines 8 new HTML semantic (semantic) elements. All of these elements are block -level elements.

In order for older browsers to display these elements correctly, you can set the CSS display property to block.

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 the HTML and defines the style for the element, named <myfirst>

Example

<!DOCTYPE html>
< html > 
< head >
 < meta charset = " utf-8 " >
 < title > Add new element to HTML </ title > 
< script > 
document.createElement ( " myHero " ) _ _
</ script >
 < style >
myHero { display: block 
     ;
     background-color: #ddd ;
     padding : 50px ;
     font-size : 30px ;
 }
</ style > </ head >
 < body > 
< h1 > My First Heading </ h1 >
 < p > My First Paragraph. </ p > 
< myHero > my first new element </ myHero > </ body > </ html > 

The JavaScript statement document.createElement(“myfirst”) adds a new element to IE browser.


Internet Explorer browser issues

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

lamp Internet Explorer 8 and earlier IE browsers do not support the above methods.
<!--[if lt IE 9]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

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