Conditional Comments broken - by Sig Weber

Status : 

  By Design<br /><br />
		The product team believes this item works according to its intended design.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

ID 572123 Comments
Status Closed Workarounds
Type Bug Repros 2
Opened 7/1/2010 5:03:17 AM
Duplicates 636728 Access Restriction Public


According to the MSDN documentation inside an HTML document special crafted comments, so called "Conditional Comments", can be used (and are strongly recommended instead of CSS hacks) to display content for a particular IE version.

The syntax is something like this:

<!--[if IE 7]>Hello Internet Explorer 7 User!<![endif]-->
<!--[if IE 8]>Hello Internet Explorer 8 User!<![endif]-->
<!--[if IE 9]>Hello Internet Explorer 9 User!<![endif]-->

But it does not work in IE 8/9 if using:

<meta http-equiv="X-UA-Compatible" content="IE=7" />
Sign in to post a comment.
Posted by R,S on 5/9/2011 at 2:16 PM
Subject: I can reproduce this bug at

On 1/20/2011 at 4:01 PM IECUSTOMIZER wrote:
>> there is no need to place it within conditional comments.
>> Ignore the warnings/errors reported by the W3c validators.

As Marat Tanalin indicated in his original bug report #636728, if you DON'T place it inside the conditional comments, it fails to validate.

On a site that claims to be "Valid HTML 5", you can ignore the warnings, but you CAN'T ignore the errors, otherwise it would no longer be "Valid HTML 5".

For example, at if you click on the "Valid HTML" link at the bottom of the page (or any page on that site), the HTML validator indicates the page is Valid HTML 5 code. But if you would remove the conditional comment around the X-UA-Compatible meta tag, you'll get the "Error: Bad value ..." error (see http://

The workaround that the site uses is to put the X-UA-Compatible: metatag in a template in a style sheet (, since the style sheet is not validated by the W3C Markup Validation Service. However, some sites may not want to go to the trouble of creating a style sheet.
Posted by Marat Tanalin on 5/4/2011 at 4:33 AM
"X-UA-Compatible: IE=edge" is _needed_ to guarantee that user cannot switch to compatibility mode _accidentally_ (this happens quite often). (Actually, for me personally it's the only usecase for X-UA-Compatible at all.) Unlike this bug report, my bug report (636728) is more clear as for the usecase.

Unfortunately it's not always possible to setup web-server to return equivalent HTTP response header. But (as I stated in bug 636728) X-UA-Compatible meta element is INVALID according to HTML5 validator.

Since X-UA-Compatible is needed only for IE at all, it's as a natural result to use IE's proprietary conditional comment to hide it from any UA different from IE itself.

It's not about IE _version_ differentiating at all (at least not always). Instead, it's about differentiating IE and non-IE.

So, to not force HTML5 code invalidity, this should be fixed.

Posted by Microsoft on 8/24/2010 at 10:16 PM
Hi Siegfried,

This is the expected behavior for X-UA-Compatible. This switches conditional comments to evaluate as if you're the version of IE specified in the meta tag. The idea is that a web developer has a site they know works in IE7 and which might depend on conditional comments as they evaluated in IE7. X-UA-Compatible is designed to be a simple way to get back the same behavior as IE7. If conditional comments always evaluated to the "true" IE version, many sites would break even though they added X-UA-Compatible.

Let us know if you have further questions about this.

Best Regards,

The Internet Explorer Team
Posted by Sig Weber on 8/18/2010 at 12:16 AM
I'm afraid I wasn't clear enough on this one :-(

The expected result is that:

- IE 7 should display "Hello Internet Explorer 7 User!"
- IE 8 should display "Hello Internet Explorer 8 User!"
- IE 9 should display "Hello Internet Explorer 9 User!"

No matter what value is used with the "X-UA-Compatible" meta tag.

Instead IE 8 and IE 9 report "Hello Internet Explorer 7 User!" when using

<meta http-equiv="X-UA-Compatible" content="IE=7" />

which is IMHO wrong because it is IE 8/9 hitting the page in IE-7 mode.

This makes quite a difference because in IE 8/9 when using "X-UA-Compatible" content="IE=7" the JavaScript and CSS interpreter works different (e.g. the JavaScript "document.documentMode" works but "document.querySelector" does not).
Posted by Microsoft on 7/26/2010 at 11:27 AM
Thank you for your feedback.

We are not currently able to reproduce this as described.

We displayed the page, but it always displays "Hello Internet Explorer 7 User!" as expected.

We value the feedback you provide. So if you have additional information that can help us recreate this issue such as a screen shot, test resulst from different machines, or additional conditions, please reactivate or submit a new bug with more details on how to reproduce the issue. You can also read the guidelines at regarding filing a good bug report.

Best regards,

The IE Team