Browser specific stylesheet tweaks

I’m amazed how different the various browsers interpret stylesheet settings. My development is against FireFox and during test, I get around to checking Internet Explorer 6. (Eventually, I’ll add IE 7 to my tests.) I always find things that don’t work or look as expected. For those who have a long history with web user interfaces, this is nothing new.

The only issue I have with my blog is spacing in lists. There is a simple hack to address this. It takes advantage of bad behavior in how IE6 and IE7 interpret settings. If you prefix a attribute keyword with and underscore (_) only IE6 and earlier will notice it. If you prefix with the pound sign (#) only IE7 will notice. So, if you place the default first and then follow with the setting for IE7 and then IE6, you can adjust for the specific browsers.

.user_style {
    height: 0px;
    #height: 15px;
    _height: 20px;
}

In the above example, the first setting will apply to all browsers; the second setting will only apply to Microsoft Internet Explorer browsers; the third setting will only apply to IE browsers 6.0 and older.

addendum: I went ahead and installed IE7 on a separate machine. In my case, it turned out the tweaks for IE6 were also the same ones needed for IE7.

One Response to “Browser specific stylesheet tweaks”

  1. musa Says:

    GREAT!