-1

I want to define a CSS rule for IE9 and below ONLY so I included this line on my style sheet:

<!--[if lte IE 9]>
.gradient {
  -ms-filter: "progid:DXImageTransform.Microsoft.gradient (GradientType=0, startColorstr=#bbb69c, endColorstr=#ffffff)";
}
<![endif]-->

it didnt work. Internet Explorer 9 is not understanding it unless I take off the conditional tags.

Why is that?

Thank you.

Pugazh
  • 9,453
  • 5
  • 33
  • 54
Cain Nuke
  • 2,843
  • 5
  • 42
  • 65

3 Answers3

0

You can only add HTML code inside conditional comments. Your page structure should be like this:

<html>
    <head>
        <link rel="stylesheet" type="text/css" href="style.css">
    </head>
    <!--[if lte IE 8]>
        <link rel="stylesheet" type="text/css" href="ie9.css">
    <![endif]-->
    <body>
        // body content goes here...
    </body>
</html>

And in ie9.css you can define your css

.gradient {
    -ms-filter: "progid:DXImageTransform.Microsoft.gradient (GradientType=0, startColorstr=#bbb69c, endColorstr=#ffffff)";
}
Mohammad Usman
  • 37,952
  • 20
  • 92
  • 95
0

Embedded the css in style tag.

<html class="ie9-fix">
    <head>
        <link rel="stylesheet" type="text/css" href="style.css">
    </head>
    <!--[if IE]>
       <style>
.gradient {
    -ms-filter: "progid:DXImageTransform.Microsoft.gradient (GradientType=0, startColorstr=#bbb69c, endColorstr=#ffffff)";
}
</style>
    <![endif]-->
    <body>
        // body content goes here...
    </body>
</html>
smirfan
  • 26
  • 3
0

Okay, I think I found the answer. This seems to work.

@media screen and (min-width:0\0) {
gradient {-ms-filter: "progid:DXImageTransform.Microsoft.gradient (GradientType=0, startColorstr=#bbb69c, endColorstr=#ffffff)";
}
Cain Nuke
  • 2,843
  • 5
  • 42
  • 65