9

I have been using the following trick to make browser-specific HTML:

<!--[if (IE)]>  <div class= "ie"> <![endif]-->
<!--[if !(IE)]><!--> <div class= "not_ie"> <!--<![endif]-->
</div>

This does not work with IE11. Any new tricks to use?

I can detect it using JavaScript:

Detecting IE11 using CSS Capability/Feature Detection

or

Object.hasOwnProperty.call(window, "ActiveXObject") && !window.ActiveXObject)

but I'm hoping to avoid that.

user984003
  • 28,050
  • 64
  • 189
  • 285
  • 5
    I'm using a font, gabriola, which is displayed differently in IE (it's not vertically centered in then element). I therefore add some extra margins. I don't really think that using this font is considered bad code, but you're entitled to your opinion, of course. – user984003 Jan 18 '14 at 12:36
  • @NielsKeurentjes unless you're writing an IE deprecation text and only want to show it to IE users (my situation). We will not support IE (all versions) and need to show a warning message to those poor people. – Spock Dec 11 '18 at 16:19
  • @Spock but for that goal JS UA based detection works just fine. My comment 5 years ago applied to IE11-specific rendering exceptions. – Niels Keurentjes Dec 11 '18 at 16:27

1 Answers1

13

IE 11 does not longer support conditional comments in your HTML code. So you have to use Javascript.

Microsoft Dev Center - IE 10+ Conditional Comments

Kevin
  • 1,633
  • 1
  • 22
  • 37