User Agent CSS
Friday, October 14, 2005 8:46:35 AM
For a few weeks now I've been working on the idea of being able to easily send different CSS styles to different browsers. My original need was to send a different display property to the Safari and Konqueror browsers to work around a bug. The end result was my development of a Perl script available on my web site:
http://www.scss.com.au/family/andrew/webdesign/uacss/
My timing of this is rather interesting. The IEBlog has recently posted The demise of CSS hacks. It's becoming more and more obvious that the current widespread use of CSS hacks is not sustainable.
Just a minute while I get up a little higher on my soapbox...
I've always thought that CSS hacks were a bad idea - especially those that rely on parser bugs or other unintended and undocumented behaviour. They were a Pandora's box that should never have been opened. Now we have a whole bunch of people bitching and moaning that Microsoft are fixing their browser hacks without fixing the CSS bugs that had people looking for the hacks in the first place.
I have no sympathy for those people. Maybe I'm being a bit harsh, but I defy anyone to honestly say that designing your software/website so that it relies on bugs for correct operation is a good idea.
Anyway, apart from bug characteristics, there are a few options still available:
My script is not immune to that sort of trouble either, but it doesn't come from the script itself, rather it comes from lazy and irresponsible web designers who might feel tempted to do:
http://www.scss.com.au/family/andrew/webdesign/uacss/
My timing of this is rather interesting. The IEBlog has recently posted The demise of CSS hacks. It's becoming more and more obvious that the current widespread use of CSS hacks is not sustainable.
Just a minute while I get up a little higher on my soapbox...
I've always thought that CSS hacks were a bad idea - especially those that rely on parser bugs or other unintended and undocumented behaviour. They were a Pandora's box that should never have been opened. Now we have a whole bunch of people bitching and moaning that Microsoft are fixing their browser hacks without fixing the CSS bugs that had people looking for the hacks in the first place.
I have no sympathy for those people. Maybe I'm being a bit harsh, but I defy anyone to honestly say that designing your software/website so that it relies on bugs for correct operation is a good idea.
Anyway, apart from bug characteristics, there are a few options still available:
- User agent sniffing (either server- or client-side)
- Conditional comments (only for IE)
My script is not immune to that sort of trouble either, but it doesn't come from the script itself, rather it comes from lazy and irresponsible web designers who might feel tempted to do:
body {
-uacss-iewin-display: none;
}There's not much that can be done about that! Ultimately, my script is just tool. It's all in how you use it. I've included some usage guidelines on my web page. It's my hope that people may find my script useful.








Rijk # Friday, October 14, 2005 1:30:51 PM
Maybe you could add even more emphasis on the guideline that the 'normal' value should be targeted at user agents that correctly implement the CSS spec - this is so crucial for forward compatability!