Targeting Firefox, IE 7, and IE 6 (and older) browsers via CSS

Thursday, August 16, 2007 Labels: ,

The tip for today's post is applying different styles to IE 7, IE 6 and older, and all the other browsers out there without having custom script or changing out style sheets. It’s simple too!

1) First, create your normal style, which of course applies to all browsers:
  padding: 2px 6px 2px 6px;
2) Then, create the style you’d like to apply only to Internet Explorer 7:
  #padding: 1px 6px 1px 6px;
3) Now, create the style to apply only to Internet Explorer 6 and older:
  /* _padding: 3px 4px 3px 4px; */

There you have it! Now you can target the three main browsers: IE 6, IE 7, and everyone else.

Technically, step 2 doesn’t only apply to IE 7, but really applies to all Internet Explorer browsers. In other words, if you wanted to target all IE browsers only steps 1 and 2 are needed.

I don’t remember where I found this. I believe parts came from a couple of different sources, but anyway, it’s a great hack – especially when used together.

Older Post Home Newer Post