To Hack Or Not To Hack

From CSS Discuss

Jump to: navigation, search

The topic of whether or not to use ((Css Hack))s is often hotly debated, and could be thought of as a Holy War. Since ((Holy War))s are by their nature long winded and boring let's keep this one tucked away on its own page where it won't bother anyone who doesn't want to be bothered.

Arguments For CSS Hacks

Simon Willison : CSS hacks help us get around the horrible mess that is CSS support in modern browsers such as Internet Explorer. Any hack that allows us to get the right effect while keeping the presentational logic separated from the markup has to be a good thing. If we later find we need to update our CSS because the hacks are no longer compatible with newer browsers we can theoretically update an entire site by editing only a few central CSS files. In my opinion this is by far preferable to markup workarounds that must be applied to every XHTML file on a site.

From Simon, at another time: I've been thinking about this issue recently and I've decided that CSS hacks are an unfortunate necessity. I'm a huge fan of structural markup, and my views on CSS hacks are based on the idea that anything which keeps the markup clean is a good thing. Provided workarounds don't involve changing the XHTML of the page I really don't see the harm of a few box model hacks (or worse) in the external CSS file - after all, with external stylesheets one file can be altered (and the hacks removed) to update a whole site. Any cross browser workarounds coded in to XHTML will end up spread like a virus across every page in the site - at least with CSS hacks they stay in one place where you can keep an eye on them ;)

If I ever get a chance to work on a site which I know will not have any IE5/5.5 visitors I'll drop the box model hack like a shot, but until then it looks like being a necessary evil.

Carl: CSS Hacks are needed simply because the web user should not have to pay a price for the mistakes of others. We should be user-oriented, which means sometimes bending the rules and creating horrid hacks. From a technical standpoint, of COURSE standards are good and useful. But there is no reason to use that as an excuse for limiting millions of users.

One final thought: not all users are in the USA or Britian, using good lines and equipment. Tell the guy in Nigeria that you don't want to give him a good experience just because he's not in a good position to upgrade.

Chriztian Steinmeier : As long as a hack is Forward Compatible and will result in ValidCSS, I would (and already do) use it to get around a bug/quirk in some browser. But having to edit my CSS half a year from now, because a hack doesn't work anymore is no fun.

Prii Or : I think it all depends on the target audience, and the importance of the web site. If i was making an e-commerce site, with the main intent of making money off the site, then I would make sure that that specific underlying principle doesn't get harmed, therefore, if hacks are to be used.. let them be used. On the other hand, for my personal sites, or sites that offer free information, as web developers we have a responsibility to promote the standards, and in a way, encourage the users to upgrade (and offer the possibility to do so). There are a few browsers out there today *cough* Mozilla Firefox *cough* that run very well on slower machines and support the standards very well.

Arguments Against CSS Hacks

Jeremy Dunck has written his views on his personal page.

Interesting thoughts:

Why CSS hacks are evil:

PPK thoughts on CSS Hacks :

The origins of the box model hack and a reflexion on hacks

Tantek Çelik, creator of the box model hack and many famous others, wrote on September 26 2005 about its genesis and consequences: "Pandora's Box (Model) of CSS Hacks And Other Good Intentions" ( is an essential read about CSS hacks.

Personal tools