The fundamental problem with CSS is it's reliance on the DOM
I’ve already argued that CSS needs to borrow from programming languages, and I wonder if the arguments designers and developers are getting into over the future of CSS have a more fundamental cause than the one’s debated so far (which boils down to the Cascade being inadequate on it’s own). To my mind the crux of the issues is this: CSS currently operates on top of the Document Object Model - a base that is ill suited for the job CSS is asked to perform, namely, the visual presentation of a webpage. We need to stop using the DOM as the sole basis for visual tasks. That sounds odd, but please hear me out.
What problems are we facing with CSS?
As CSS has aged, the progress of the specification has slowed, and the capabilities of CSS have not kept pace with the requirements of designers. There are a number of reasons for this, as have been explored at length in a number of articles1 from many influential designers and developers over the past few months.
Baring the odd problem, such as the bad attitude toward CSS (and CSS authors) some of the CSS WG hold2, the main issue is one of technology implementations that make good visual design incompatible with good development practice.
We’re all good developers and designers now, and we have stopped using tables for layout and stopped thinking of HTML as a presentation language. We know that HTML is the semantics of the document. We also know that the DOM is the programmatic skeleton of that HTML document. The trouble with HTML defining only semantic data is that the DOM itself represents only the semantic elements within a document. Because CSS can only be applied to elements within the DOM, that in turn means that CSS can only be applied to elements that have distinct semantic properties within the document. The trouble is that designers don’t want to style the semantic elements alone, we want to style all sorts of bits and bobs that have no semantic anchor and therefore no representation in the HTML/DOM.
People at the W3C seem quite adamant that CSS’s job is to style elements within a document. And while the web was happy to have nicely coloured hyperlinks, and slightly better typography, that was fine, because those visual changes mapped perfectly to actual mark-up. But time and big business has changed what users want from the websites they visit - things have to be pretty these days. Not functionally pretty, but artistically pretty. And making things pretty is often an exercise in graphic manipulation independent of the available HTML content anchors. Sometimes we want to shove a pretty graphic somewhere on a page where there isn’t any content to attach it to. CSS has already changed objective from it’s initial conception - it’s not about styling the semantic content of a document, it’s about the visual presentation of a webpage. Those are two very different things; visual presentation of a page is quite independent of the semantic content. So the way in which CSS works - mapping visual effects to DOM elements - is itself a problem, because that doesn’t always map to what designers actually want to do.
Arguments about the progress of CSS and the way forward with the specification
- Alex Russell: The W3C Cannot Save Us
- Alex Russell: CSS3, a Giant Serving of FAIL
- Ian Hickson: CSS WG has the wrong attitude
- Jeff Croft: Do We Need a Return to Browser Wars?
- Kyle Neath: HTML5 and CSS3 Doomed to Disaster
- Ian Hickson: Bert Bos should not be leading the CSS WG
Bert Bos’s attitude
It’s hard to understand why, but after 14yrs of designers repeatedly voicing their need for a more powerful CSS, Bert Bos still manages to argue that designers demands for CSS variables are wrong. If we’re still asking the same thing 14yrs later, that’s evidence itself that CSS isn’t delivering what we need, and that we know what we need. Alex Russel has a very good rebuttal of Bert’s article; CSS variables are the future.