The ontology problem (in CSS)

Too Many Spellings!

This table illustrates up one of my fundamental annoyances with CSS. Here are five common ways to emphasize text using CSS; below are the properties and values you need to specify:

font-weight: bold
font-decoration: underline
font-style: italic
font-variant: small-caps
texttransform: all-caps

Five different ways to do it. One of them doesn’t even have the word ‘font’ in it, though perhaps that’s best, given that many non-technical people don’t consider any of these a ‘font’ operation–they work on text.

The problem is, each of these choices makes sense in isolation. Bold really is about font weight. And we should let people change the weight by itself. We may want semi-bold, so let’s allow that. And some people might want more control, so let’s support a number too, from (for some reason) from 100 to 900, but only in steps of 100. For now.

And yeah, ‘italic’ is a style for your font. So’s ‘oblique’, and you can’t have those at the same time. (But is this an important distinction? While an oblique italic may look horrid, so do most obliques by themselves, and people use them all the time.) Let’s make it a new property, and allow only these two values (plus ‘normal’, of course).

Oh, and small caps is a variant. (Of course, you could argue italics and bold are also variants.) Let’s put that in ‘font-variant’, even if ‘small-caps’ is the only possible value (again, other than ‘normal’).

Each of these choices makes sense individually. It’s just when you see them all together that you shake your head and strain your memory. “Is small-caps a style, or a decoration?”

The Thingification Of Things

The problem is one of ontology–how to build trees of meaning.

When learning a computer science degree, sooner or later you have to build an ontology of Things. You know–the teacher says, “Describe all the things on a dinner table, organized by type.”

Things are pretty easy to start with. Cup, plate, spoon, fork, knife. Steak knife, butter knife. You can group things fairly simply–cups and plates are ‘dishware’. Steak and butter knives are ‘knives’. Knives (of whatever type) join up with spoons and forks and become ‘flatware’.

(Ignore for the moment that ‘dishware’ and ‘flatware’ make no sense as names, and were in fact coined by some poor person who had to do this many years past.)

And of course you need this all in one tree, so you create ‘tableware’ which includes both dishware and flatware. Or maybe ‘Object’, or ‘Thing’, which everything is descended from.

But then you get to the paring knife next to the turkey, and the serving spoon stuck in the stuffing. They’re clearly flatware–but they’re also serving utensils. And really, they’re more like the serving bowl, which is flatware, but is also a serving…well, can’t call it utensil. Call it “servingware”…but do serving knives go under that, or under flatware? Or both?

Now you’ve got things in two “places”. That’s the fundamental problem CSS has. David Weinberger wrote a great book about this problem (Everything Is Miscellaneous). Forcing things to live in a single place is an artifact of the real world, where physics makes us choose.

In the information domain, it’s far better to let people put things in multiple places. This is the idea behind ‘tags’ and ‘folksonomies’, and that works fine for content. Put ‘paring knife’ in ‘knife’ and ‘paring’ and ‘servingware’ and ‘tableware’ and ‘flatware’, all of it, and everyone’s happy, right?

The Usability Of The Little Languages

But for languages it’s much more difficult–you’re trying to define a formal grammar. Right? So you have to very specific. Everything must have a single expansion. We must define a context-sensitive grammar, because I learned Backus-Naur Form as an undergrad and remember that it’s trivial to write a parser for it.

But at what cost to CSS authors? How bad would it be, really, if was able to write “font: bold small-caps italic”? How hard would that be, really, to interpret? The alternative is remembering the three hundred and twenty different special cases that currently make up CSS3, and that’s not very usable. Sure–my text editor can often help me out, proposing the right property when I start typing. I still have to remember that the correct spelling of ‘all caps’ starts with a ‘t’.

The web took off due to a permissive syntax–HTML tries its darndest to make sense out of whatever malformed string you hand it. Is it time for permissive CSS?

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s