yamahamm
yamahamm

Reputation: 103

IE special stylesheet

I have a webpage (to be exact: a game) and it works differently on IE and other browsers. I googled for this and it still doesn't work.

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

Then I tried adding

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

and still nothing.

This is a coding issue, isn't it...?

Upvotes: 0

Views: 89

Answers (4)

El Kabong
El Kabong

Reputation: 717

It depends on the version of IE - conditional comments are no longer supported. You can see the answer to a similar question here:

Why doesn't Internet Explorer 11 honour conditional comments even when emulating Internet Explorer 8 document mode?

I use Modernizr to solve this with feature detection:

Modernizr.load({
            test: Modernizr.canvas,
            nope: ['Content/Site-ie-8.min.css', 'Content/font-awesome-ie7.min.css']

        });

you can read more about Modernizr here: http://modernizr.com

Upvotes: 1

beautifulcoder
beautifulcoder

Reputation: 11340

Try a lt sign as such

[if lt IE 10 ]

IE 10 and above behave more like other browsers.

Upvotes: 0

Matteo Scotuzzi
Matteo Scotuzzi

Reputation: 886

The syntax is correct but from internet explorer 10 [0] on, conditional comments have been removed, that's why you are not seeing the expected behaviour.

[0] http://msdn.microsoft.com/en-us/library/ie/hh801214(v=vs.85).aspx

Upvotes: 2

Ignacio Correia
Ignacio Correia

Reputation: 3668

More details can be found here.

Target ALL VERSIONS of IE

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

Target everything EXCEPT IE

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

Target IE 7 ONLY

<!--[if IE 7]>

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

Target IE 6 ONLY

<!--[if IE 6]>

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

Target IE 5 ONLY

<!--[if IE 5]>

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

Target IE 5.5 ONLY

<!--[if IE 5.5000]>

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

Target IE 6 and LOWER

<!--[if lt IE 7]>

<link rel="stylesheet" type="text/css" href="ie6-and-down.css" />
<![endif]-->

<!--[if lte IE 6]>

<link rel="stylesheet" type="text/css" href="ie6-and-down.css" />
<![endif]-->

Target IE 7 and LOWER

<!--[if lt IE 8]>

<link rel="stylesheet" type="text/css" href="ie7-and-down.css" />
<![endif]-->
<!--[if lte IE 7]>

<link rel="stylesheet" type="text/css" href="ie7-and-down.css" />
<![endif]-->

Target IE 8 and LOWER

<!--[if lt IE 9]>

<link rel="stylesheet" type="text/css" href="ie8-and-down.css" />
<![endif]-->
<!--[if lte IE 8]>

<link rel="stylesheet" type="text/css" href="ie8-and-down.css" />
<![endif]-->

Target IE 6 and HIGHER

<!--[if gt IE 5.5]>

<link rel="stylesheet" type="text/css" href="ie6-and-up.css" />
<![endif]-->
<!--[if gte IE 6]>

<link rel="stylesheet" type="text/css" href="ie6-and-up.css" />
<![endif]-->

Target IE 7 and HIGHER

<!--[if gt IE 6]>

<link rel="stylesheet" type="text/css" href="ie7-and-up.css" />
<![endif]-->
<!--[if gte IE 7]>

<link rel="stylesheet" type="text/css" href="ie7-and-up.css" />
<![endif]-->

Target IE 8 and HIGHER

<!--[if gt IE 7]>

<link rel="stylesheet" type="text/css" href="ie8-and-up.css" />
<![endif]-->
<!--[if gte IE 8]>

<link rel="stylesheet" type="text/css" href="ie8-and-up.css" />
<![endif]-->

Upvotes: 1

Related Questions