Scott Isaacs, one of the Microsoft web chaps, is complaining about CSS hacks. His proposed solution is to, instead of applying CSS hacks to make a browser do what you want, instead have details of the users browser inserted into the HTML element either by server-side or client-side script. So, if you visit a page using IE6.0, it would add
class="ie m6 d0 win" to the HTML element; using Firefox 1.06 on Linux it would add
class="firefox m1 d06 linux", and so on. Then, in your stylesheet, use these hooks to apply style for specific browsers.
I think that this is not a good idea, and here’s why.
Secondly, it clutters the HTML a bit. Not much, but a bit. This isn’t much of an objection.
Thirdly, how do you establish the platform and short-name-for-a-browser and major and minor versions? Parse the userAgent string? That takes us back to the days of browscap.ini and The World’s Biggest List Of Browsers, which you have to rely on someone to maintain.
In short, I don’t like the idea. I’d be interested in hearing dissenting opinions, though.
(Incidentally, you may be thinking that this should have been a comment over at Scott’s rather than a post here: I agree with you, but to post there you need an MSN passport and I don’t want to get one.)