HTML5 support on browsers

You can teach browsers how to handle HTML5 properly.

You can teach browsers how to handle HTML5 properly.

Browser supports HTML5

HTML5 is supported on most modern browsers. Browsers, whether new or old, automatically handle elements that they don't know as an inline element. Therefore, you need to 'teach' it to know how to handle new HTML elements. Even IE6 (on Windows XP 2001) can "teach" it.

Define syntax elements for block elements

HTML defines 8 new syntax elements, all at the block level. To ensure correct display on the old browser, you can set the display properties for these elements to the form of blocks.

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

Add new elements to HTML

You can also add new elements to the HTML page, as the example below adds a named element and defines its style.









Title


Phần tử myHero


Use the JavaScript command document.createElement ('myHero') to create new elements on IE9 and earlier versions.

Problems with Internet Explorer 8

It is possible to use the above solution for all new HTML5 elements. But IE8 and earlier versions do not allow styling on elements it does not know.

So Sjoerd Visscher created HTML5Shiv. This is a JavaScript alternative, allowing styling for HTML5 elements on IE 8 and earlier versions.

HTML5Shiv syntax

HTML5Shiv is placed in the tag, which is the JavaScript file referenced in the tag

Example of HTML5Shiv

If you do not want to download and store HTML5Shiv on your site, you can refer to the version on the CDN page. The HTML5Shiv script must be placed in the element.











Technology page




Network administrator


Network administration is the technology site, providing the latest technology guides, tips and news.






Link download HTML5Shiv https://github.com/aFarkas/html5shiv or refer to CDN version https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js

Previous article: Introduction to HTML5

The following article: New elements in HTML5

Update 25 May 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile