The Folly of Depending on CSS Parsing Bugs

I meant to write something about Zeldman’s post earlier, but never ended up getting around to it (being very tied up putting off all kinds of other, more important things). However, Hyatt’s CSS Parser update reminded me about it.

My two cents: Zeldman is completely and totally wrong on this issue. I would not compensate for CSS rendering bugs by exploiting CSS parsing bugs except as a last resort. Think about it from a standardized test perspective: what strong relation does CSS rendering bugs have with CSS parsing bugs? There’s no reason (nor right!) to assume that all future browsers with the same rendering bugs will have the same parsing bugs (and vice versa). In fact, if you look at the recent past releases (Safari, Opera, IE), even within browser families you’ll see that this is absolutely not true!

By Zeldman’s own argument, using CSS parsing/rendering relation-hacks are a bigger money-pit than per-browser rules. Instead of if-statements for fixes, you’re dealing with a cartesian product of pain. This is a magnitude more complex than plain ol’ browser sniffing!

At the end of the day, everyone has to weigh for themselves the importance of ease of maintenance and user-agent specific rendering code, but if you need to implement the latter (and chances are, if you’re doing this web stuff for a living, you will), then your two choices are really either client-side or server-side sniffing . If done properly*, it’ll save you much headache.

* This, of course is the central issue. While for DOM support I’m much more of a browsercaps type of guy, for CSS rendering fixes, it’s really about specific versions. Organize the conditions into family’s and then create per major-version branch which contain the fixes (I do agree with Zeldman here that you probably don’t want to be sending completely different files). It’s then up to you whether to restrict these conditions to the specific version (v5) or to future versions as well (v5+); both have their pros and cons (MSN caught flack for doing the latter). If dealing with a bug, I generally pick the former, holding the optimistic view that the next version will fix the rendering bug.

In summary, if your designer tells you to use CSS parsing hacks to do filtering, please give him a good smack.