KillerSites Blog

Using CSS hacks is just plain stupid

February 9, 2005

The Web Standards movement has created a ‘culture of hacks’ to compensate for browser incompatibilities (OK, mostly IE) and this is a bad idea.

Before anyone attempts to tell me that the Web Standards community does not promote the use of hacks, please refer to just about every book written on Web Standards based web design.

Why were hacks promoted?

In a nutshell: those who promoted them are inexperienced … in other words: green. It is simply bad practice to rely on broken aspects of a technology in an attempt to make things work – any programmer worth his salt knows this. And that is exactly what many/most hacks rely on – broken aspects of Internet Explorer.


Anecdote: I’ve often had to ‘slap-down’ young-pup programmers (just a few years out of school,) when they’ve tried to introduce into the code base, what would be the equivalent of CSS hacks.

CSS hacks are a recipe for disaster that I’ve been predicting for a while, a disaster that seems to be happening: it looks as though IE7 will be breaking CSS hacks and thus, the Web Standards myth of forward compatibility.

I’ve used a hack: I’m a god-curse hypocrite:

Yes, I’m guilty of ‘following the pack’ and I’ve used a single CSS hack (child of div hack) but I used it in a minimal way – should the hack fail (and it will in IE7,) my layouts will still work though the pixels will shift a little.

The real problem occurs when you start using many hacks or if your hacks should fail, your website’s usability will be severely compromised.

If you have to use hacks, use them very delicately.

The hack-free cross browser compatible solution:

When you’re critical of something, you should try to present alternatives … and my alternative to using brittle CSS hacks:

Use a IE conditional comments, Microsoft intelligent solution to cross browser coding.

I know, I know … Microsoft coming up with an intelligent solution!?

🙂

Stefan Mischook (a.k.a: The Web Design Heretic )