Currently, most browsers supportHTML5. However, some lower version browsers have some problems with HTML5 support.
Lower version browsers support HTML5
all browsers, and unrecognizable elements will be automatically processed asinline elements. Therefore, you can use the following method to teach the browser to handle "unknown" HTML elements.
Defining HTML5 elements as block elements
HTML5 defines 8 new HTML semantic elements. All these elements are block-level elements.
In order to allow older versions of browsers to display these elements correctly, you can set thedisplayattribute of CSS to block:
header, section, footer, aside, nav, main, article, figure { display: block; }
Copy after login
Add new Element
The following example adds a new element to HTML and defines a style for the element. The element name is
:
为 HTML 添加新元素
我的第一个标题
我的第一个段落。
我的第一个新元素
Copy after login
document.createElement( "myElement") is to add new elements to IE browser.
Internet Explorer browser problem
You can use the above method to add new elements to the browser, but IE8 and below cannot support this method.
We can use the "HTML5 Enabling
JavaScript", "shiv" created by Sjoerd Visscher to solve this problem:
or
The above code is , when the IE browser version is smaller than IE9, the html5.js file will be read and parsed. The former one is the national Google resource, and the latter one is the domestic Baidu resource.
For
IE browserhtml5shiv is a better solution. html5shiv mainly solves the problem that the new elements proposed by HTML5 are not recognized by IE6-8. These new elements cannot be used as parent nodes to wrap child elements, and CSS styles cannot be applied.
The following is an example of using the html5shiv solution:
渲染 HTML5
我的第一个HTML5页面
Hello,world!
Copy after login
The above is the detailed content of Detailed explanation of HTML5 browser compatibility solutions. For more information, please follow other related articles on the PHP Chinese website!