5

I have the following in my html document.

<!--[if (IE)]><!-->  i am IE <!--<![endif]-->
<!--[if !(IE)]><!--> i am not ie <!--<![endif]-->

When viewed in IE it properly says "i am IE"

When viewed in Chrome/Firefox it incorrectly says "i am IE i am not ie" instead of "i am not IE"

http://jsfiddle.net/Hgx97/

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
user984003
  • 28,050
  • 64
  • 189
  • 285

2 Answers2

12

You're incorrectly terminating the IE conditional comments on the first line, so other browsers will see the content between the delimiters (you can also see how the text is highlighted black on the first line, which is not what you want):

<!--[if (IE)]>       i am IE <![endif]-->
<!--[if !(IE)]><!--> i am not ie <!--<![endif]-->

The second line is correct since you want to show that content to non-IE browsers.

Updated fiddle

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
2

should've used

<!--[if IE]>i am IE<![endif]-->
<![if !(IE)]>i am not ie<![endif]>

reference : about usage of conditional statement,

view #example part if you want to know more

Valen
  • 1,693
  • 1
  • 20
  • 17
  • Add some description about reference you have provided or add some part of it to your answer so that other can understand it better. – Yagnesh Agola Dec 03 '14 at 12:38