Target Browser Versions in CSS

I recently ran across a scenario in which IE6 and IE7 were rendering CSS differently, which affected the HTML output of one of my web sites. Not good! What I discovered as a way around this is that there are built-in browser hacks that you can take advantage of in a CSS file to target specific browser types. Basically, the operators * and _ (asterisk and underscore) can be used preceding a style element in CSS to target browsers. Here's an example:

.box {

background: #00f; /* all browsers including Mac IE */

*background: #f00; /* IE 7 and below */

_background: #f60; /* IE 6 and below */

}

 

What did you think of this article?




Trackbacks
  • No trackbacks exist for this post.
Comments
  • No comments exist for this post.
Leave a comment

Submitted comments are subject to moderation before being displayed.

 Enter the above security code (required)

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.