« Previous entry | Next entry » Browse > Snippets
Skip to comments (4)
CSS for IE only
Posted by Erik on Nov 01 2005 @ 17:18 :: 3168 unique visits
Today I came across a usefull method to only show CSS to IE.I alwais used the e > e { } trick to only execute some CSS to Firefox but now I can also do it the other way around.
I am not talking about conditional comments.
This is different in the following ways:
- It allows you to write conditional CSS directly in your stylesheet file, and doesn’t require inline styles
- It works for IE 5.0, 5.5 and 6.0
- It’s very simple to work with
The method is called the "Underscore Hack":
CODE: CSS
body {
background: green; /* executed by FireFox/Other normal browsers */
_background: red; /* executed by IE only */
}
background: green; /* executed by FireFox/Other normal browsers */
_background: red; /* executed by IE only */
}
There is only 1 disadvantage and that is that the CSS won’t validate anymore.
4 comments posted so far
Add your own »
2. On Nov 02 2005 @ 15:22 guest wrote:
<style type="text/css">/* standards compliant CSS goes here */
<!--[if IE]>
/* IE - only CSS goes here */
<![endif]-->
</style>
3. On Nov 04 2005 @ 14:43 toran wrote:
<3...
1. On Nov 02 2005 @ 11:57 Jos wrote:
For an overview of CSS hacks, check out this page.It's much better to avoid hacks though.