About the quality of our style sheets
An opinion about our industry’s handling of CSS
(This is a translation of Jens’s post at heise online, colspan=9: Über die Qualität unserer Stylesheets. We’re publishing it here because it reflects Jens’s position regarding HTML and CSS at sum.cumo, too – though that’s not to say this post was an official position of sum.cumo as a whole.)
The craft of CSS is dying, it’s easy to claim these days. But is style sheet quality that important at all? The opposite position appears legitimate just as well. A few thoughts.
In the CSS world, validation has never been a big priority. For that there are three reasons: One, mistakes usually show immediately; two, style sheets are normally separated and then maintained in few places, making problems easier to handle; and three, it’s been necessary for a long time now to use experimental properties which often result in validation false positives – and through that stupefy developers.
DRY CSS has never been en vogue, either. That appears so easily said but we have enough data that declaration repetition in particular has always been a problem. We repeat ourselves often and quickly in CSS.
The performance of style sheets has been a topic, yet rather owed to a misunderstanding of the impact of slow selectors and declaration values, because for selectors we know that in practice, selector performance can essentially be ignored.
CSS Wild West
If the simplest way to determine the quality of a style sheet (validation) gets ignored and principles like the avoidance of code duplication shunned and the remaining items end up being hyped rather than assessed critically, what remains? Nothing, one could argue. As we live CSS it’s like the Wild West and “everything goes.” (That’s the position I’ve once assumed at A List Apart.) Whether that was always the case is not something I’d want to insist on. But what I find interesting is the question whether this is at all a problem.
From a professional point of view, from a craft point of view I’d say: absolutely. To simply type down CSS without paying attention to syntactical correctness, to then repeat oneself x times, to then micro-optimize the outcome, that doesn’t seem to match the picture of an expert and professional.
Yet apparently the world hasn’t ended in the last 20 years, it hasn’t yet exploded, even when we measurably observe these different problems. Style sheets generally ship with a number of issues and still they don’t appear tooo bad. They’re obviously not that terrible that anything would happen, anyone would move and a good number of experts seems to detect no problems whatsoever.
From that angle, now, we may ask: Practically speaking, what exactly makes for quality style sheets? Maybe we can say that the underlying standards are quite well-designed. That they are so robust that for that precise reason the world doesn’t end. And perhaps, too, that separation of concerns, which stubbornly refuses to die even after concepts like “Atomic CSS,” works, that the benefit of separation of structure from presentation has been proven. Perhaps that is something, the only thing, we can leave standing and fall back on these days.