IE Stylsheets/ Conditional comments Not working

Iqbal Khan picture Iqbal Khan · Dec 21, 2012 · Viewed 12.1k times · Source

I am trying to make a website look better in IE, so i decided to use conditional comments. So I used this conditional comment to link to the stylesheet.

<!--[if IE]>
<link rel="stylesheet" type="text/css" href="IEstyle.css" />
<![end if]-->

That doesn't work, and it will either use the default stylesheet or it will display a blank page. So then i read somewhere that the comments were like this.

<!--[if !IE]>-->
<link rel="stylesheet" type="text/css" href="IEstyle.css" />
<!--<![endif]-->

So i tried that and it did the exact same thing as the other one but the --> shows up on the page. I am still somewhat new to html, and any help would be nice.

Answer

mkoryak picture mkoryak · Dec 21, 2012

Here is the correct format of the comment:

<!--[if IE ]>
Special instructions for IE here
<![endif]-->

here is a NOT IE comment:

<!--[if !IE ]>
According to the conditional comment this is not IE
<![endif]-->

source: http://www.quirksmode.org/css/condcom.html

edit: just noticed that their 'not' example is wrong. i have corrected it.