Forum Moderators: not2easy
background-color: green;
<!--[if IE]>
background-color: red;
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=75);
<![endif]-->
I.e. if it's transparent in MSIE, I want it to be red not green.
The color however is green. The opacity filter is applied as expected.
I am expecting MSIE to read the "red" statement, and override anything preceding in the cascade.
Why is this not working?
the IE conditional comment must be separated from the main stylesheet in this manner...
<style type="text/css">
body {
background-color: green;
}
</style><!--[if IE]>
<style type="text/css">
body {
background-color: red;
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=75);
}
</style>
<![endif]-->
birdbrain
...I should have said, this is an embedded stylesheet, not external -
shouldn't the conditional comment work in that manner?
The example that I provided is an embedded stylesheet.
Did you mean inline styling?
If so you would need to do it like this...
<!--[if !IE]><!-->
<body style="background-color:green">
<!--<![endif]--><!--[if IE ]>
<body style="background-color:red;filter:alpha(opacity=75);">
<![endif]-->
is actually a html comment ( <!-- comment -->), so it only works where you have html, not inside CSS.
Now inside that comment you can add html. Inside that html you can add e.g. embedded css or links to external stylesheets,
e..g to use external stylesheets:
<link rel="stylesheet" type="text/css" href="/style.css" />
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="/ie6.css" />
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="/ie7.css" />
<![endif]-->
e.g. to include Javascript for legacy IE versions:
<!--[if lt IE 8]>
<script src="http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE8.js" type="text/javascript"></script>
<![endif]-->
or you can add html code like:
...
<body>
<!--[if lt IE 8]>
<h1 id="legacybrowser">Upgrade your browser!</h1>
<![endif]-->
<!--[if IE 8]>
<h1 id="IE8">Congrats for keeping your browser current!</h1>
<![endif]-->
...
I'd be very careful with targeting IE8 along with IE6 and IE7, it's a different beast from IE6 and IE7.