1

I use this code to set style in ie8 and ie9, and this is not working.

<!--[if lt IE 8,9]>
    <link href="~/Styles/ie8-9.css" type="text/css" rel="stylesheet" />
<![endif]-->

but this code worked properly:

<!--[if lt IE 8,9]>
    <style>
         body{color:red;}
    </style>
<![endif]-->

how can I fix the first case?

user3748973
  • 449
  • 2
  • 8
  • 24
  • Name of file ? Path of file? Are you sure is right? – DaniP Jan 29 '15 at 16:09
  • yes, i'm sure. i use visual studio. – user3748973 Jan 29 '15 at 16:11
  • The second one shouldn't work - that CSS needs to be in a ` – henry Jan 29 '15 at 17:17

3 Answers3

0

ADD<!DOCTYPE html> in the top of your html page, it will work if not Try this:

*::-ms-backdrop, body{color:red !important;}
rajesh
  • 1,475
  • 10
  • 23
0

I think the problem is that the path to your ie8-9.css is wrong. Check the console for any errors.

Maybe this article is interesting for you: slash(/) vs tilde slash (~/) in style sheet path in asp.net

Furthermore, instead of

<!--[if lt IE 8,9]>

I suggest you to write

<!--[if (IE 8)|(IE 9)]>

if you want to use the stylesheet only for IE 8 and 9. I'm not sure if the syntax you are using is correct.

Maybe you also reached the maximum of 31 stylesheets per page in IE 8 and 9.

Don't test with such tools like IETester because they are not 100% equal to the real browsers. Go to modern.ie and download a virtual machine to test your site.

Other ressources:

Community
  • 1
  • 1
0

lt means "less than". What you're looking for is a conditional statement that handles if the browser is equal to IE 8 or IE 9 so you need to do something like the following:

<!--[if IE 8]>
    <link href="~/Styles/ie8-9.css" type="text/css" rel="stylesheet" />
<![endif]-->
<!--[if IE 9]>
    <link href="~/Styles/ie8-9.css" type="text/css" rel="stylesheet" />
<![endif]-->
mikelt21
  • 2,728
  • 4
  • 23
  • 33