Asked by Andrew a freelance designer from Chicago
How come when i have the “if IE” link to the css, it doesn’t change at all?
It’s linked correctly and the “if IE” is correct, but the css just isn’t showing.
I think cause the link to the regular css is over-riding the “if IE” one. Why won’t it work?
Right off the top of my head.
If you are using multiple versions of Internet Explorer on the same machine you will experience issues with version targeting like “If IE”.So if you are using a Standalone IE6 or Standalone IE7, refer to the manufacturers of the standalones for workarounds.
Conditional comments and version targeting
Conditional comments only work in Internet Explorer, and are used to target specific versions. They use the HTML Comment structure, and thus are placed in the HTML not the CSS.
Example
<!–[if IE 6]>
<link href=”../ie6.css” rel=”stylesheet” ………. />
<![endif]–>
This makes them perfect for linking to alternate IE only stylesheets, which for example, wouldn’t use 24-bit PNG transparency etc.
Troubleshooting
This script comes off the very handy Quirksmode.org website. It will run through the different versions available to show you what your browser is behaving as.
From: http://www.quirksmode.org/css/condcom.html
<p><!–[if IE]>
According to the conditional comment this is Internet Explorer<br />
<![endif]–>
<!–[if IE 5]>
According to the conditional comment this is Internet Explorer 5<br />
<![endif]–>
<!–[if IE 5.0]>
According to the conditional comment this is Internet Explorer 5.0<br />
<![endif]–>
<!–[if IE 5.5]>
According to the conditional comment this is Internet Explorer 5.5<br />
<![endif]–>
<!–[if IE 6]>
According to the conditional comment this is Internet Explorer 6<br />
<![endif]–>
<!–[if IE 7]>
According to the conditional comment this is Internet Explorer 7<br />
<![endif]–>
<!–[if gte IE 5]>
According to the conditional comment this is Internet Explorer 5 and up<br />
<![endif]–>
<!–[if lt IE 6]>
According to the conditional comment this is Internet Explorer lower than 6<br />
<![endif]–>
<!–[if lte IE 5.5]>
According to the conditional comment this is Internet Explorer lower or equal to 5.5<br />
<![endif]–>
<!–[if gt IE 6]>
According to the conditional comment this is Internet Explorer greater than 6<br />
<![endif]–>
</p>
Its always preferable to avoid using conditional targeting and try to work within the css to support the major browsers, but unfortunately the real world sometimes calls for harsher measures.
For the adventurous, try the conditional comments and mix them with progressive enhancement.
See more posts under: Tips & Tweaks
OR see posts tagged with: compatability | css | internet explorer
You may also like:
OR follow on Twitter
Twitter.com/DeDestruct
Comments
Good article. One thing though: I think you mean 32-bit PNG. 24-bit PNG’s don’t have transparency.
I believe that 24bit PNGs have variable transparency which is alpha transparency
i could be wrong, going to do some research on all the differences between
8/24/32 bit PNGs
Thanks! But one more thing, when I have the other CSS (the IE css), do i have to have the whole entire CSS in it? And not just the parts that fix the stuff in IE? Otherwise thank you soo much! You guys are a great help.
Just the IE parts
What was the conditional statement for firefox??? Do you write:
[if lte Firefox] or [if lte Mozilla]???
there is no conditional stament for firefox sadly
I’m sure that later, they will have it, and it would be [if Mozilla] or maybe [if M] or [if Mz] or [if Ml] or something.
I am not a big fan of these kind of conditional statements. I feel the website is better of to use markup that works for all browsers in all situations. If you need help I have a great CSS template cheats resource http://www.zachgraeve.com/css-cheats/ that can eliminate a lot of guess work when creating a CSS driven layout.
zacheos’s last blog post… Shiny Orb Button / Icon - Powered by CommentLuv
Trackbacks
Leave a reply