CSS Tags Specific to Browser [IE6, IE7]

I came across this posting on Ed Eliot's blog and had NO idea this existed but it made my life a lot easier.  Full credit goes to him on this - the below is cut and pasted directly from his blog so I know where to find it in the future.  The URL for this post on his blog is:
http://www.ejeliot.com/blog/63

.box {
background: #00f; /* all browsers including Mac IE */
*background: #f00; /* IE 7 and below */
_background: #f60; /* IE 6 and below */
padding: 7px;
color: #fff;
}
I think it speaks for itself.  In my case, I easily fixed my annoying IE6 problem by applying a negative bottom margin that only applies to IE6.  Perfect.  I have used conditional statements to load CSS files based on your browser, but this is really helpful for those elements where you need to apply a tag to an element here or there - no point in creating an entirely different CSS file for things like this.

Update [12.9.2008], I also came across a Safari specific hack...
.submit {margin: 20px;}
.hint {right: 168px#;} /* Safari will ignore tags with the pound sign and EVERYTHING THAT FOLLOWS */
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Print | posted @ Thursday, August 28, 2008 11:46 AM

Twitter