Now browser sniffing is basically a bad thing but there is still a need to fix / hack issues on older browsers, in particular Internet Explorer. Okay, almost entirely in Internet Explorer. IE6 may be -mostly- dead, but IE8 will be around for a long time given that there is no IE9 for WinXP. (See Detecting a Mobile Browser on the Server in your Rails app for one reason server side agent sniffing and how to do so.)
The “traditional way” to correct IE issues is using a conditional css style sheet (in the head section ) to load an additional style sheet after the default styles specific to that browser version and take advantage of the cascading part of Cascading Style Sheets (CSS) like so:
The conditional comments tag is a proprietary IE tag, introduced in IE5, and only works in IE, and “are thus excellently suited to give special instructions meant only for IE”. (IE10 will not support this tag, because it will render perfect HTML5. No ,really.)
I have become aware of a slightly different way to do this via the new hotness of doing feature sniffing ( or Object Detection ) via Modernizer. Modernizer’s trick of loading (or over loading 🙂 ) classes on the tag can be used not only be used for its JavaScript-driven feature detection for html5, but also for creating a top-level class that apply styling to that an individual page or type of page. For a more general description see Why use Classes or IDs on the HTML element?
So technique of “Classes on the HTML tag” was demonstrated by Paul Irish’s back in 2008 (lots of good updates and info there) and a a variation of it is used in Html5 Boilerplate :