Pew Pew Laser Blog

Code. Glass art. Games. Baking. Cats. From Seattle, Washington and various sundry satellite locations.

Pew Pew Laser Blog Archives — by Blog ID

Quick And Easy CSS Targeting.


I have been a staunch staunch supporter of conditional comments as the best way to send different CSS to different versions of Internet Explorer. I found that the other options - selector-based CSS rules - were just too hack-y. I was going to have to see a very persuasive technique for me to consider it.

Here it is:

  { color: #999; /* shows in all browsers */
    *color: #999; /* notice the * for IE7 and below */
    _color: #999; /* notice the _ for IE6 and below */

The above code is lifted directly from

These are still hacks, so there's always the possibility that the browser vendor could fix the bug that these hacks exploit, or that a new browser will react oddly to this code. For a short term site or a quick and dirty build, I might be willing to take that chance.

I think I'll stick with conditional comments for my larger endeavors. I'm willing to subject the IE6/7 users to the hit of an extra HTTP request.


Tags: code css web-development

Authorized users may log-in to leave a comment.

Last Blog: Stuck in a Rut?

Next Blog: Potion Vase.