3 ms·
The author recommends two ways to target rules at IE: 1) create new stylesheets for each version of IE, or 2) CSS hacks that only IE understand/ignores. But I
by audionerd 17y ago
The author recommends two ways to target rules at IE: 1) create new stylesheets for each version of IE, or 2) CSS hacks that only IE understand/ignores.
But I prefer to use a different approach: conditional classes on the body tag. For example:
<!--[if lt IE 7 ]> <body class="ie6"> <![endif]-->
<!--[if IE 7 ]> <body class="ie7"> <![endif]-->
<!--[if IE 8 ]> <body class="ie8"> <![endif]-->
<!--[if !IE]><!--> <body> <!--<![endif]-->
Then you can write IE-specific rules without CSS hacks:
body div#container { background-color: white; }
body.ie6 div#container { background-color: red; }
And all your related styles can be grouped together in the same file.
via http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ http://paulirish.com/2008/conditional-stylesheets-vs-css-hac... and http://www.paulhammond.org/2008/10/conditional/ http://www.paulhammond.org/2008/10/conditional/
- deleted 17y ago[deleted]
- run4yourlives 17y agoThe beauty of separating the styles into new style sheets is that an non IE user doesn't need to download all that extra IE crap. It's also much, much easier to maintain and minimizes the code you need to write, allowing for proper style cascades.