Goodbye conditional comments

The very first article I wrote on this blog, back in July 2006, was titled Goodbye hacks. Hello conditional comments. In that post I discussed how conditional comments could be used to feed different stylesheets to older version of Internet Explorer, smoothing differences between browser rendering engines without resorting to CSS hacks.

Conditional comments have provided a great stopgap measure while we wait for obsolete versions of IE to fall into disuse, but as the market share of IE6 and IE7 has dwindled I’ve found myself relying on them less and less. In fact, I can’t remember the last time I resorted to a separate stylesheet to make an old browser behave.

Last week Microsoft announced that support for conditional comments will be dropped from version 10 of Internet Explorer. Like other modern browsers IE10 will treat conditional comments just like regular HTML comments, and ignore them. This is a very encouraging sign, since it means that Microsoft are confidant that IE’s support for web standards has reached a level where a standards compliant website ought to “just work” across all modern web browsers, without having to make special allowances for legacy rendering engines.

Of course, conditional comments will continue to be recognised by older versions of IE, but with IE6 and IE7 ready to disappear off the radar the time is clearly right for conditional comments to be put out to pasture. Goodbye conditional comments.

3 thoughts on “Goodbye conditional comments

  1. Rick says:

    I was reading last night about IE10 dropping conditional comment support. That’s fine provided it treats them in exactly the same way as down-level/non-ie browsers. I often use a ‘down-level reveal’ CC syntax to pass a stylesheet to recent IE versions AND non-IE browsers. Eg:

    <!--[if (IE 7)|(IE 8)|(IE 9)]><!-->
    IE v. 7-9 AND non-IE browsers all see this content
    <!-- <![endif]-->

    So I would want to certain that IE10 would see that content as well and not skip over/ignore the whole block.

  2. Jonathan says:

    @Rick – I’ve never used downlevel-revealed comments, but I can see why you’d be concerned.

    Because IE10 won’t support conditional comments I imagine it will treat the first and third lines in your example as standard HTML comments.

    But, this is Microsoft we’re talking about here, I guess anything is possible…

  3. Rick says:

    @Jonathan: Yes. Logically, if IE 10 does not support conditional comments, then it should see the same content as /any other/ browser that does not support conditional comments — in which case all is well, and it *will* see the content line in the example above. But, as you say, this is Microsoft… and logic is not always the trump card.

Comments are closed.