Posted By

michellebracken on 08/18/11


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

spee66


Target IE7 (and below) and IE6 (specifically) without Conditional Comments


 / Published in: CSS
 

We all know how difficult IE can sometimes be when it comes to CSS. However instead of cursing IE under your breath or out loud you can easily write IE specific code that other browsers will ignore. My own preference is for conditional comments, but here’s a quick trick you can use in your main CSS file.

With the exception of IE, all browsers will ignore the asterisk in front of the property. Everything other than IE6 will ignore the underscore. The order of the properties is very important due to CSS precedence rules.

  1. 1 .element {
  2. 2 background: red; /* modern browsers */
  3. 3 *background: green; /* IE 7 and below */
  4. 4 _background: blue; /* IE6 exclusively */
  5. 5 }

Report this snippet  

You need to login to post a comment.