CSS: To Hack or Not To Hack
Tantek Çelik has written an interesting post on CSS hacks entitled Pandora’s Box (Model) of CSS Hacks And Other Good Intentions. Definitely worth the read.
It is a problem with all kinds of programming, that when people initially start to learn, the idea of the hack is one that has much appeal. Pushing the limits, doing more than can be done normally, seems like such a good idea. Yet the more you hack, the more your applications become unmanageable and at the mercy of external future upgrades. While your validated, non-hack CSS will most likely be supported by browsers way into the future (much longer than it will be needed); those hacks have no such guarantee.
Tantek sums it up:
- First try to simply author standards-based cross browser designs.
- Validate, validate, validate.
- Check any browser differences to see if your code is perhaps depending on an implicit browser default style sheet (like the example of the visible empty <legend> in IE6/Windows), and specify that styling explicitly instead of depending on the defaults.
- Use CSS hacks and filters sparingly (and only as needed) to get non-compliant obsolete/abandoned browsers to comply to your presentational wishes.
- And keep the pressure on the browser vendors to implement the web standards all of us web developers depend on to get our jobs done.
While they are all good steps, #4 is the biggest one for me (with vast amounts of emphasis on sparingly). I’d even suggest that part of step 4 should be asking oneself whether the feature that is breaking is worth the hack?

RSS Feed









April 27th, 2006 at 5:52 pm
Thats a really great article! Thanks for linking it.
October 24th, 2006 at 9:42 pm
What about IE7?