I thought I remembered reading somewhere that IE9 would not be supporting them, but now after searching I can't find any indication that this is true.
Is anyone aware of a definitive statement, either way, about whether Microsoft will be supporting conditional comments in IE9?
Conditional comments use a special syntax—HTML markup wrapped in a conditional statement—and are placed within an HTML comment. If the statement evaluates to true , the enclosed HTML is revealed within the HTML document. If the statement evaluates to false, the enclosed HTML remains hidden.
Conditional comments are conditional statements to hide or provide HTML source code from Internet Explorer. 2. There are two types of conditional comments - downlevel-hidden - which is used to hide HTML source and downlevel-revealed which is used to reveal HTML source code in Internet Explorer.
Conditional comments are a simple Internet-Explorer-only feature that Microsoft added to IE5 Windows and later. (Mac IE doesn't support them.) They provide an easy way to detect that the visitor is using an IE browser (and which version they're using). You can then serve IE users different blocks of HTML as required.
--[if IE]> syntax, resolves the if and parses the content of the conditional comment as if it were normal page content. Since conditional comments use the HTML comment structure, they can only be included in HTML files, and not in CSS files.
The Platform Preview supports them, fire it up (or download it, then fire it up) and see this example - http://jsbin.com/axaju3:
<!--[if IE 9]> <p>You are using IE 9</p> <![endif]-->
Tested in IE 9 Document Mode.
Straight from the horse's mouth, EricLaw from the IE team has confirmed in the comments below that CCs are still available in IE9.
A recent post on the IE blog shows that, as part of the effort to get consistent cross-browser HTML5 parsing, conditional comments will not work in IE10's rendering engine:
<!--[if IE]> This content is ignored in IE10 and other browsers. In older versions of IE it renders as part of the page. <![endif]-->
This is true as of Platform Preview 2 and the author suggests you should use feature detection as an alternative.
Internet Explorer 9 will be the last version to support conditional comments. With the release of Internet Explorer 10, Microsoft is turning over a new leaf. According to the MSDN article on Conditional Comments:
Support for conditional comments has been removed in Windows Internet Explorer 10 Release Preview standards and quirks modes for improved interoperability and compliance with HTML5. This means that Conditional Comments are now treated as regular comments, just like in other browsers. This change can impact pages written exclusively for Windows Internet Explorer or pages that use browser sniffing to alter their behavior in Internet Explorer.
While this will not affect the majority of sites online, there's a chance it may affect yours. If it does, please consider making use of the x-ua-compatible meta tag or header to instruct Internet Explorer to Emulate Internet Explorer 9 (the last version to support conditional comments):
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9">
Note that this will prevent you from having access to the newest features of the browser, like broader support for HTML5, and CSS3, as well as more JavaScript APIs.
The best solution is to ween yourself off of conditional comments. With Internet Explorer 10, Microsoft's browser will begin to operate much the same way other popular browsers do, requiring less attention to writing IE-specific code, as well as removing the need for conditional comments altogether.
Conditional Comments aren't the only thing to become obsolete in IE10. There's more.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With