Posted By

alozuldo on 10/24/10


Tagged

css hack browser ie6 conditional ie7 target comments


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

alozuldo


Target IE6 and IE7 Browsers without Conditional Comments


 / Published in: CSS
 

URL: http://sixrevisions.com/css/10-random-css-tricks-you-might-want-to-know-about/

The code below will change the background-color of divs depending on what browser the user is viewing the web page under. Since * cascades down to IE7 and below, we use _ after that declaration so that IE6 (and below) has a different background color from IE7.

  1. div {
  2. background-color: #999; /* all browsers */
  3. *background-color: #ccc; /* add a * before the property - IE7 and below */
  4. _background-color: #000; /* add a _ before the property - IE6 and below */
  5. }

Report this snippet  

You need to login to post a comment.