HTML5 Browser Support
You can make some older browsers (that do not support HTML5) support HTML5.
HTML5 Browser Support
Modern browsers all support HTML5.
In addition, all browsers, both old and new, automatically handle unrecognized elements as inline elements.
Because of this, you can "teach" browsers to handle "File %s type is: %s%n" HTML elements.
![]() |
You can even teach the IE6 (Windows XP 2001) browser to handle unknown HTML elements. |
|---|
Defining HTML5 Elements as Block Elements
HTML5 defines 8 new HTML semantic elements. All of these elements are block-level .
To make older browsers display these elements correctly, you can set the CSS display property value to block:
Example
header
,
section
,
footer
,
aside
,
nav
,
main
,
article
,
figure
{
display:
block
;
}
Adding New Elements to HTML
You can add new elements to HTML.
This example adds a new element to HTML and defines a style for it; the element name is
Example
<!DOCTYPE html><html>
<head>
<meta charset="utf-8">
<title>Adding New Elements to HTML
title
<
script
document.
createElement
(
"
myHero
"
)
script
<
style
myHero
{display:
block
;
background-color:
#ddd
;
padding:
50
px
;
font-size:
30
px
;
}
style
head
<
body
<
h1My first heading
h1
<
p
My first paragraph.
p
<
myHero
My First New Element
myHero
body
html
Try it »
JavaScript Statements document.createElement("myHero") is used to add new elements for the IE browser.
Internet Explorer Browser Issues
You can use the above method to add HTML5 elements for the IE browser, but:
![]() |
Internet Explorer 8 and earlier IE versions do not support the above method. |
|---|
We can use "HTML5 Enabling JavaScript", "** shiv**", created by Sjoerd Visscher, to solve this problem:
The above code is a comment that makes browsers with an IE version lower than IE9 read and parse the html5.js file.
**Note:** Users in China please use this site's static resource library (the Google library is unstable in China):
html5shiv is a good solution for the IE browser. html5shiv mainly solves the problem that the new elements introduced by HTML5 are not recognized by IE6-8; these new elements cannot act as parent nodes to wrap child elements, and CSS styles cannot be applied to them.
The Perfect Shiv Solution
Example
<!DOCTYPE html><html>
<head>
<meta charset="utf-8">
<title>Rendering HTML5
title
head
<
body
<
h1My First Article
h1
<
article
Runoob Tutorial - Learning is not only about technology, but also about dreams!!!
article
body
html
Try it »
The html5shiv.js reference code must be placed in the element, because the IE browser needs to load this file first when parsing new HTML5 elements.
