IE10 and X-UA-Compatible

Published 2012-02-05 03:30 by Leif Halvard Silli.

Except in quirks mode, IE10 will not react to conditional comments.

Thus, to make IE10 react to the X-UA-Compatible directive, one must either create a page that triggers quirks-mode per the rules of HTML5 (that is: an a page with no doctype). One can also send the directive as a HTTP header, however: A HTTP sent directive appears to have no effect if you use it to downgrade the rendering — it can only be used to upgrade the rendering.

Let us take that in more detail

For IE8-IE9, if the author wants to include the X-UA-Compatible directive inside the code, there is one way or another way which allows you to hide the directive inside a conditional comment and thus stay HTML5-conforming.

In IE10, this hiding trick does not work anymore. Well — the hiding trick works, actually … But only if the HTML code (the HTTP header does’t matter) triggers quirks-mode, then X-UA-Compatible can be used to override the mode of the code.

Thus in IE10, if you want to do it with code, there is only one way, if you want to hide the X-UA-Compatible in the code: a quirks-mode page. Such as this one:

<!-- No DOCTYPE here! -->
<html><head>
<!--[if ie]><meta http-equiv=X-UA-Compatible content="IE=Edge" /><![endif]-->
</head>
Why does it need quirks mode in order to react to conditional comments?

Simple: Since IE10 defaults to HTML5 parsing, it has to be in non-HTML5 parsing mode in order to react to <!--[if ie]><meta http-equiv=X-UA-Compatible content="IE=Edge" /><![endif]-->. Nevertheless: It is a bit weired that you must set the page to quirks mode in order to trigger standards mode…

HTTP

According to my tests, if a HTTP X-UA-Compatible header says IE=5, but the page is a valid HTML5 page and thus has a valid DOCTYPE, then the page will override the HTTP header, resulting in standards mode.

Invalid code, but correct DOCTYPE

If the page has correct doctype, then one can use the X-UA-Compatible meta element, though, as long as one does not hide it inside a conditional comment.

Recommendation

Question is: Do we need to use X-UA-Compatible in IE10? I don’t think so. And for that reason, I would recommend to continue to use one of the hiding tricks that I linked to above, to trigger standards mode — or IE=Edge in Microsoft lingo — in IE8 and IE9. Because for IE10, then it looks like it no longer has a special mode for intranet pages. And it looks like IE10 has implemented HTML5 parsing, sot that X-UA-Compatible has no use, provided you are after HTML5 rendering.

Caveat: This text is based on the current preview version of IE10.


|