0

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...?

embert
  • 7,336
  • 10
  • 49
  • 78
yamahamm
  • 103
  • 1
  • 10

4 Answers4

2

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

Matteo Scotuzzi
  • 846
  • 8
  • 8
1

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]-->
Ignacio Correia
  • 3,611
  • 8
  • 39
  • 68
1

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

Community
  • 1
  • 1
El Kabong
  • 717
  • 1
  • 8
  • 15
0

Try a lt sign as such

[if lt IE 10 ]

IE 10 and above behave more like other browsers.

beautifulcoder
  • 10,832
  • 3
  • 19
  • 29