Search code examples
htmlinternet-explorerconditional-comments

Conditional comment to include content where IE > 8 or !IE?


On my website I have found that web fonts look really nasty on older versions of Internet Explorer, so I decided to use conditional commenting. Given that IE10+ no longer supports conditional comments I thought that the following might work:

<!--[if gt IE 8]> -->
<link blah... />
<!-- <![endif]-->

Whilst this comment is behaving properly in IE7 and IE8, it does not seem to be working properly in IE9 (under simulation mode in IE10). The text --> is shown at the very start of the page.

The following conditional comment doesn't exhibit this behaviour:

<!--[if !IE]> -->
<link blah... />
<!-- <![endif]-->

How can I reliably perform this conditional inclusion where !IE or IE > 8?


Solution

  • Not quite sure how I missed this, but this question has already been asked before here on StackOverflow. I guess my initial search criteria wasn't good enough.

    As per the following answer: IE Conditional operator: OR ... if is greater than ie9 or not IE

    <!--[if gt IE 8]><!-->
    <link blah... />
    <!--<![endif]-->