CSS Hacked Off

Published on 20 January 2004 in , , , , ,

Every morning I peruse Paul Hammond’s Links thanks to a handy email that gets sent out. It’s a varied selection of stuff that he’s found interesting.

This morning one of the links was a big long list of CSS Hacks.

I’ve seen similar lists before – although not that extensive on the browsers included. Hey, I’ve even created lists like that for work purposes back in my days of client side development.

And it scared me. It scared me then, it scares me now.

To my mind there are two kinds of hacks – ‘unsupported’ hacks and ‘parsing-abuse’ hacks.

‘Unsupported’ hacks are like using an @import to hide your CSS from older browsers. That’s fine in my book – it’s common enough so that browser manufacturers know that if they don’t have a certain level of CSS support, they should not include @import capabilities. To my mind they’re not hacks – they’re just making use of documented defincines in the browser – making use of the fact that the browser doesn’t support a valid use of CSS.

On the other hand, there are ‘parse abuse’ bugs – generally making use of some obscure parsing bug in the browser – a bug that should not be there. They’re undocumented and undesired.

Tantek’s Box Model Hack is the best known. A collection of manipulating voice-family, back slashes, curley brackes and duplication means that you can hide things from IE5.5 and below.

They’re hideous things that I won’t touch with a bargepole (there are ways round them which whilst clunky, are at least understandable). To my mind they are just asking for trouble. They are often obscure and could cause no end of trouble. All it takes is for one new browser to implement them by accident (or deliberatly – hey Omniweb used to claim support for the evil Netscape 4 document.layers in JavaScript) and you could have no end of problems for your website.

All it actually takes is one major browser manufacturer to do it, and web developers could find their sites in chaos – imagine if the next version of Mozilla, Safari or IE had one of those parsing bugs! Or fixed one! That could be a lot of broken websites.

Now imagine that it’s a commercial website built by an external agency, or a developer who has left and not replaced…

I’m still hitting commercial sites that don’t allow non-IE users in, ar are broken Mozilla Firebird because they’ve been built years ago for different browsers. And no doubt in a few years time, the same will be happeing with CSS hacks.

And no doubt by then, there will be yet another problem introduced by people looking for a quick and easy way round things just waiting to bite us in the future…