Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE Stylsheets/ Conditional comments Not working

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.

like image 955
Iqbal Khan Avatar asked Dec 21 '12 04:12

Iqbal Khan


3 Answers

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.

like image 102
mkoryak Avatar answered Nov 02 '22 21:11

mkoryak


You should use like this : Syntax :

<!--[if IE 8]> = IE8
<!--[if lt IE 8]> = IE7 or below
<!--[if gte IE 8]> = greater than or equal to IE8


<!--[if IE 8]>
<style type="text/css">
    /* css for IE 8 */
</style>
<![endif]-->

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

reference link 1

reference link 2

like image 2
Surinder ツ Avatar answered Nov 02 '22 23:11

Surinder ツ


Also its always good to declare what versions of IE you want to pull up the conditional sheet, for example if you want IE 9 and lower it would be as stated below.

<!--[if lte IE 9]>
<link rel="stylesheet" type="text/css" href="IEstyle.css" />
<![endif]-->
like image 1
MoMark media Avatar answered Nov 02 '22 21:11

MoMark media