Celebrating CSS

Cascading Style Sheets turned 20 years old this week. Happy birthtime, CeeSusS!

Bruce interviewed Håkon about the creation of CSS, and it makes for fascinating reading. If you want to dig even deeper, here’s Håkon’s 1994 thesis comparing competing approaches to style sheets.

CSS gets a tough rap. I remember talking to Douglas Crockford about CSS. I’ll paraphrase his stance as “Kill it with fire!” To be fair, he was mostly talking about the lack of a decent layout system in CSS—something that’s only really getting remedied now.

Most of the flak directed at CSS comes from smart programmers, decrying its lack of power. As a declarative language, it lacks even the most basic features of even the simplest procedural language. How are serious programmers supposed to write their serious programmes with such a primitive feature set?

But I think this mindset misses out a crucial facet of understanding CSS: it’s not about us. By us, I mean professional web developers. And when I say it’s not about us, I mean it’s not only about us.

The web is for everyone. That doesn’t just mean that it’s for everyone to use—the web is for everyone to create. That means that the core building blocks of the web need to be learnable by everyone, not just programmers.

I get nervous when I see web browsers gaining powerful features that can only be accessed via a JavaScript API. Geolocation is one example: it doesn’t have any declarative equivalent to its JavaScript implementation. Counter-examples would be video and audio: you can use the JavaScript API to get exactly the behaviour you want, if you’ve got that level of knowledge …or you can use the video and audio elements if you’re okay with letting web browsers handle the complexity of display and playback.

I think that CSS hits a nice sweet spot, balancing learnability and power. I love the fact that every bit of CSS ever written comes down to the same basic pattern:

selector {
    property: value;
}

That’s it!

How amazing is it that one simple pattern can scale to encompass a whole wide world of visual design variety?

Think about the revolution that CSS has gone through in recent years: OOCSS, SMACSS, BEM …these are fundamentally new ways of approaching front-end development, and yet none of these approaches required any changes to be made to the CSS specification. The power and flexibility was already available within its simple selector-property-value pattern.

Mind you, that modularity was compromised when we got things like named animations; a pattern that breaks out of the encapsulation model of CSS. Variables in CSS also break out of the modularity pattern.

Personally, I don’t think there’s any reason to have variables in the CSS language; it’s enough to have them in pre-processing tools. Variables add enormous value for developers, and no value at all for end users. As long as developers can use variables—and they can, with Sass and LESS—I don’t think we need to further complicate CSS.

Bert Bos wrote an exhaustive list of design principles for web standards. There’s some crossover with Tim Berners-Lee’s principles of design, with ideas such as modularity and robustness. Personally, I think that Bert and Håkon did a pretty damn good job of balancing principles like learnability, extensibility, longevity, interoperability and a host of other factors while still producing something powerful enough to scale for the whole web.

There’s one important phrase I want to highlight in the abstract of the 20 year old CSS proposal:

The proposed scheme provides a simple mapping between HTML elements and presentation hints.

Hints.

Every line of CSS you write is a suggestion. You are not dictating how the HTML should be rendered; you are suggesting how the HTML should be rendered. I find that to be a very liberating and empowering idea.

My only regret is that—twenty years on from the birth of CSS—web browsers are killing the very idea of user stylesheets. Along with “view source”, this feature really drove home the idea that professional web developers are not the only ones who have a say in what gets rendered in web browsers …and that the web truly is for everyone.

Have you published a response to this? :

Responses

Aaron Gustafson

As usual, Jeremy sums up my thoughts perfectly:

Personally, I don’t think there’s any reason to have variables in the CSS language; it’s enough to have them in pre-processing tools. Variables add enormous value for developers, and no value at all for end users.

Read on Adactio’s Journal

George Papadakis

@adactio CSS is JS’s alter ego. Similar complains, similar resistance.

If you treat any of those 2 as a language, you treat then wrong.

6 Shares

# Shared by glenn gustitus on Tuesday, November 4th, 2014 at 8:19pm

# Shared by Nick Sayre on Tuesday, November 4th, 2014 at 8:23pm

# Shared by enderFP on Tuesday, November 4th, 2014 at 8:24pm

# Shared by Christof on Tuesday, November 4th, 2014 at 8:40pm

# Shared by Scott Kellum on Tuesday, November 4th, 2014 at 9:05pm

# Shared by ali dark on Wednesday, November 5th, 2014 at 12:54pm

23 Likes

# Liked by Jim Purbrick on Saturday, October 18th, 2014 at 1:22pm

# Liked by Anders Ringqvist on Tuesday, November 4th, 2014 at 8:24pm

# Liked by JohnQ on Tuesday, November 4th, 2014 at 8:24pm

# Liked by Luca Degasperi on Tuesday, November 4th, 2014 at 8:25pm

# Liked by glenn gustitus on Tuesday, November 4th, 2014 at 8:25pm

# Liked by Simon Collison on Tuesday, November 4th, 2014 at 8:32pm

# Liked by vollepeer on Tuesday, November 4th, 2014 at 8:33pm

# Liked by Brad Frost on Tuesday, November 4th, 2014 at 8:33pm

# Liked by Doug Reid on Tuesday, November 4th, 2014 at 8:44pm

# Liked by Scott Kellum on Tuesday, November 4th, 2014 at 9:03pm

# Liked by Benjamin Parry on Tuesday, November 4th, 2014 at 9:04pm

# Liked by Luke Armstrong on Tuesday, November 4th, 2014 at 9:13pm

# Liked by Brian Leavitt on Tuesday, November 4th, 2014 at 9:25pm

# Liked by Anselm Hannemann on Tuesday, November 4th, 2014 at 9:47pm

# Liked by Vince Brown on Tuesday, November 4th, 2014 at 10:08pm

# Liked by ToeFoo Bar on Wednesday, November 5th, 2014 at 12:24am

# Liked by Vinci the Cat ☂ on Wednesday, November 5th, 2014 at 2:10am

# Liked by Arild Rotmo on Wednesday, November 5th, 2014 at 7:57am

# Liked by Denise on Wednesday, November 5th, 2014 at 9:20am

# Liked by Kyeong, Lee on Thursday, November 6th, 2014 at 5:12am

# Liked by Simon St.Laurent on Monday, November 17th, 2014 at 10:54pm

# Liked by Valeria Brigatti on Monday, November 17th, 2014 at 10:54pm

# Liked by Jan Skovgaard on Saturday, March 14th, 2015 at 5:53pm

Previously on this day

6 years ago I wrote Listen to dConstruct 2013

For your huffduffing pleasure.

10 years ago I wrote Optimisation

Optimise for ugly bags of mostly water, not your plastic pal that’s fun to be with.

12 years ago I wrote Semantic brevity

Make microformats work with your writing style.

18 years ago I wrote The roots of conflict

Here’s some more grist for the fundamentalist mill.

18 years ago I wrote Falwell-Robertson-Bin Laden Quiz

This is too perfect.