The history of CSS hacks

Tantek Çelik’s post Pandora’s Box (Model) of CSS Hacks And Other Good Intentions recaptures the history of CSS hacks and filters. In the early days CSS filters were used mainly to completely hide stylesheets from obsolete browsers like Netscape 4. However, once a way of sending one value to Internet Explorer 5.x for Windows and another to browsers that support the W3C box model was discovered, things changed:

Once said Pandora’s Box was opened, it didn’t take long for the notion that hacking CSS was a “good idea” to spread far and wide in the web design and development community

Tantek goes on to urge developers to really think things through and try to find another solution before resorting to CSS hacks:

Use CSS hacks and filters sparingly (and only as needed) to get non-compliant obsolete/abandoned browsers to comply to your presentational wishes.

Another very important message in Tantek’s post is aimed at browser manufacturers:

CSS2(.1) doesn’t say you can implement part of the spec. You’re supposed to implement the whole spec in the first place.

Wouldn’t it be great if all browser manufacturers could agree on that, and implement the whole CSS 2.1 spec properly and without bugs? Not very likely, but one can always hope…

Until then, I’m going to continue trying my hardest to avoid sending different CSS to different browsers.

Posted on December 9, 2005 in CSS, Quicklinks

Comments

  1. Using Conditional comments I think you can get away with sending diffrent css to diffrent browsers.

    Using hacks you migth find yourself in an acward place when IE7 comes to make our lives hell on earth.

    Its a bit more hassle than a simple hack, but I think we’ll look back on hack’s as we do on table layout.

  2. Thankfully its a big might, as many of the things that will be fixed will mean that the hacks become useless as the browser understands the correct method (We hope).

    I am however a little annoyed at a few of the other standards advocates, the ones that have been preaching the use of such things for so long, and then suddenly change face, being more than slightly hypocritical.

    I understand that it is very important to learn from your mistakes, but thats no excuse to be an arse to others who have not caught on yet.

  3. Well, one should only hack dead browsers. That has always been a good rule of thumb.

    IE6 has been dead (not under development) for years now, so it has been a legitimate target in my opinion. Looks like they will fix enough in IE7 so that not even ‘conditional comments’ will be needed to hide old IE6 hacks from it. Hope it will come up to spec too.

    New browsers should be fed progressive rules that they should pick up and turn into something useful, without breaking anything, as soon as they are up to spec. That’s not hacking, as we can’t wait until everything is working perfectly across browser-land before applying new styles.

Comments are disabled for this post (read why), but if you have spotted an error or have additional info that you think should be in this post, feel free to contact me.