Been looking for an IE7 CSS hack? Been looking for an Opera hack? Odds are, you can find something around here. This is one of the most comprehensive CSS hack sites I’ve seen. By far, the best part is how granular this site gets: just about every browser you’re going to find is covered.
My thoughts on cascading style sheets hacks? Well, since you’ll be using them to correct Internet Explorer’s bad behavior, you should use what Internet Explorer gives you: conditional comments. Use conditional comments to keep IE fixes in a separate CSS file. That’s what I like to do when I have the time: it keeps the "good" code separate from the "bad." Plus, if Microsoft releases any fixes, you need only to adjust the conditional comment; since Microsoft’s conditional comments allow tests against browser version, you’ll be a lot safer with conditional comments. Plus, it keeps your regular stylesheets clean.
If conditional comments aren’t your thing (perhaps because they’re not traditional markup, although they do validate), you can try minimized attribute selectors. Why? Because minimized attribute selectors let you separate IE and Firefox/Opera/Safari CSS selectors into separate blocks. Create an IE block, then "fix" that code in a minimized attribute selector on the line below. This clearly separates IE corrections from compliant code. Unfortunately, these types of selectors aren’t XHTML compliant and are basically out if you’re writing XHTML.
This leads to my final choice, the one I’d probably recommend if conditional comments are out of the picture: exploiting IE’s failure to support media selectors on @import rules. This works almost the same way as conditional comments do, but instead of placing IE code in a separate file, you place compliant code in a separate file, which you then import to correct your IE CSS. Instead of keeping "good" code in your main stylesheet, you use the hack to correct the bad code.
I strongly recommend conditional comments: they’re the cleanest way to render CSS across browsers, and they are flexible enough to allow you to avoid using hacks in your code. If browser compatibility changes, just update the condition. Plus, there’s no nasty hacks that may be corrected in future browser releases hanging around in your stylesheets. But, if the best option isn’t your option, it’s nice to know there are other ways to make your pages render correctly cross-browser.
technorati tags:css, ie7, browser, hack, stylesheets, cascading, conditional, comments, css, hacks