Parsing

Internet Explorer 10 and Windows apps using JavaScript fully support the HTML5 parsing algorithm, continuing the effort started in previous releases toward making HTML "just work" in the same way across browsers. This effort has included supporting Scalable Vector Graphics (SVG)-in-HTML, HTML5 semantic elements, preserving the structure of unknown elements, and improving whitespace handling.

HTML5 parsing rules

The goal of the Windows Internet Explorer team's work on the HTML parser has been for all HTML to parse the same across modern browsers. This is possible because HTML5 is the first version of HTML to fully define HTML parsing rules, down to the last edge case and error condition. Even if your markup is invalid, HTML5 still defines how to parse it, and Internet Explorer 10 follows these rules. The following parsing examples show how some cases are fixed as part of these improvements.

HTML Document Object Model (DOM) (HTML5 + Internet Explorer 10) DOM (Windows Internet Explorer 9)

<b>1<i>2</b>

|- <b>

|- "1"

|- <i>

|- "2"

|- <b>

|- "1"

|- <i>

|- "2"

|- <i>

<p>Test 1

<object>

<p>Test 2

</object>

|- <p>

|- "Test 1\n"

|- <object>

|- "\n "

|- <p>

|- "Test 2\n"

|- <p>

|- "Test 1\n"

|- <object>

|- "\n "

|- <p>

|- "Test 2\n"

 

Interoperable innerHTML

These improvements apply to innerHTML as well. Code patterns like the following now work as you would expect in Internet Explorer 10.

var select = document.createElement("select");
select.innerHTML = "<option>one</option><option>two</option>";
var table = document.createElement("table");
table.innerHTML = "<tr><td>one</td><td>two</td></tr>";

Better error reporting for developers

HTML5 ensures markup will parse consistently, but developers should still aim to write valid markup from the onset. Writing valid markup means your site works the way you expect and is more compatible with older browsers.

To help developers write consistently valid markup, Internet Explorer 10 now reports HTML parsing errors through the F12 developer tools, as shown in the following screenshot.

Note  F12 developer tools are not available in Windows apps using JavaScript.

 

Legacy features removed

Because some features in earlier versions of Internet Explorer aren't compatible with HTML5 parsing, they have been removed from IE10 mode in Internet Explorer 10. Sites that rely on the legacy features in this section will still work when running in legacy compatibility modes. This way, a site that works today will continue to work with Internet Explorer 10 even if the site's developers don't have the time or resources to update it. (For more information about compatibility modes, see Defining Document Compatibility on MSDN.)

Conditional comments

You can still use conditional comments such as the one shown here, but they will target only older versions of Internet Explorer. If you need to distinguish between more recent browsers, use feature detection instead.

<!--[if IE]>
This content is ignored in Internet Explorer 10 and other browsers.
In older versions of Internet Explorer, this renders as part of the page.
<![endif]-->

Element behaviors

Element behaviors, introduced in Microsoft Internet Explorer 5.5 and shown here, are no longer recognized in Internet Explorer 10 in IE10 mode.

<html xmlns:my>
<?import namespace="my" implementation="my.htc">
<my:element>
This parses as an unknown element in Internet Explorer 10 and other browsers.
In older versions of Internet Explorer, this markup binds to "my.htc".
</my:element>
</html>

XML data islands

XML data islands, introduced in Microsoft Internet Explorer 5 and shown here, are no longer parsed as XML in Internet Explorer 10 in IE10 mode.

<xml>
This parses as <b>HTML</b> in Internet Explorer 10 and other browsers.
In older versions of Internet Explorer, it parses as XML.
</xml>

IEBlog posts

HTML5 Parsing in IE10

Interoperable HTML Parsing in IE9

Specification

HTML5: Section 8.2