Article introduction of Wulin.com (www.vevb.com): How to make IE support new HTML5 elements.
When we use the new HTML5 elements, tags that can perform well in other browsers (such as Section, article, header and footer) are a challenge for the IE browser. The reason for the problem is the parsing mechanism of the IE browser. These tag elements that cannot be unrecognized lead to the error display of document objects.
To illustrate this issue, please see the following short code:
1
2
3
4
5
<body>
<section>
<p>This is an example</p>
</section>
</body>
Strangely, IE6-IE8 cannot parse the <section> tag, causing the Dom node to look like the following:
Note that IE browser creates two empty elements. One is section and the other is /SECTION. It is true that it takes the end tag that is not recognized as a start tag.
Here is a convenient way to solve this problem, which was first implemented. The most basic concept of this method is to create unknown elements by using document.createElement(tagName). The IE parser will recognize these elements and analyze and display them in a more reasonable and effective way. For example, we can use the following code:
1
document.createElement(section);
In this way, the above code will look like the following after parsing:
This technology allows IE6, IE7 and Ie8 to parse unknown elements.
For convenience, Remy Sharp wrote a piece of code that can enhance the display of new HTML5 elements, which you can easily download and use.published a simple script
This code is correct for other browsers, such as Opera 9, Firefox 3 and Safari 3, to parse these new elements by default. Although there are some problems in Firefox2, no solution to these problems has been found. However, compared with IE's update speed, Firefox is not a problem.
We cannot apply the labels created by this method to print styles. If you want to know if the IE printing style is correct, please check the following article Print HTML5 elements in IE browser (IE Print Protector)
Original Chinese: How to make IE support new HTML5 elements
Original English: Supporting New Elements in IE