Conditional Classnames
Tuesday, October 21st, 2008
Paul Hammond has a very clever idea about avoiding conditional sytlesheets for Internet Explorer. Basically, if we just use conditional comments for IE to include a classname in the body tag, we can isolate the specific IE rules in the main stylesheet.
Pros
- Avoids any extra HTTP requests for files with IE-only hacks
- Slicker than including that monstrosity inside the head tag
- Allows for easier reading and maintenance of stylesheets. The IE hacks can be placed where they’re relevant in the stylesheet.
Cons
- Doesn’t this defeat the entire idea of separating out hacks from standard CSS?
Does anyone else have opinions on the matter?