Why doesn't Internet Explorer 11 honour conditional comments even when emulating Internet Explorer 8 document mode?
I'm using the new Internet Explorer 11 developer tools to switch the document mode to "8", but conditional comments are still ignored, that is, they are not properly parsed and behave like normal comments. So any referenced file inside the conditional comment is not requested/loaded by the browser.
Why does this happen? Is it a bug?
If you think that this is indeed a bug that needs to be fixed, please go in and say that you too can reproduce this on the Microsoft bug report that is reported for this issue:
Conditional comments do not work when emulating document modes via F12 Developer Tools.
Update: This issue has been reported to be fixed in the mentioned bug report.
According to Jacob Rossi [MSFT]
This should be fixed in Update 1 for IE11, released last week.
That was posted on April 22, 2014.
In running a few tests myself it does appear that this was fixed and all is running smoothly again for testing the most amazing browser ever produced...Internet Explorer!
I just tried using this in Internet Explorer 11 on Windows 7 to make sure my used HTML5 semantic elements were being created for Internet Explorer 8 and below (via conditional comments), and the browser simply ignores them. -_-
This feature worked perfectly fine in Internet Explorer 10, and Microsoft just had to tinker with it, didn't they?
<!--[if lte IE 8]><script src="ie8-html5.js"></script><![endif]-->
Apart from this, I'm actually enjoying Internet Explorer, which makes for a change.
This worked for me and seems like the most elegant/easy fix (Internet Explorer 10 and Internet Explorer 11 I guess are the only browsers that support -ms-high-contract
):
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
/* IE10+ specific styles go here */
}
I recently ran into the same problem. I also found that some conditional comments work:
-
gt
andlt
worked fine -
gte
andlte
never worked
So one potential solution would be to change the conditional statements to use the gt
and lt
operators.
The other alternative, which I found more useful, was to use a service like browserstack.
I have another solution for this.
Internet Explorer 11 with Internet Explorer 8 compatibility mode turned on contains the string 'MSIE 8.0', so:
(PHP example)
if (strpos($_SERVER['HTTP_USER_AGENT'],'MSIE 8.0') !== false) {
$head[] = sprintf('<link rel="stylesheet" href="ie8.css" />');
}