Responsive Design

Form Follows Function

Object-Oriented CSS is Born

A long time ago, as we emerged from the early days of CSS and began building increasingly larger sites and systems, we struggled to develop some sound conventions to wrangle our ever-growing CSS files. Out of that mess came object-oriented CSS.

Our systems for safely building complex, reusable components created a metastasizing classitis problem—to the point where our markup today is too often written in the service of our CSS, instead of the other way around. If we try to write semantic, accessible markup, we’re still forced to tack on author-defined meanings to satisfy our CSS. Both our markup and our CSS reflect a time when we could only define objects with what we had: divs and classes. When in doubt, add more of both. It was safer, especially for older browsers, so we oriented around the most generic objects we could find.

A door, a Tree, and a Cat

Today, we can move beyond that. We can define better objects. We can create semantic, descriptive, and meaningful CSS that understands what it is describing and is as rich and accessible as the best modern markup. We can define the elephant instead of saying things like .pillar and .waterspout.

Clearing a few things up

But before we turn to defining better objects, let’s back up a bit and talk about what’s wrong with our objects today, with a little help from cartoonist Gary Larson.

Larson once drew a Far Side cartoon in which a man carries around paint and marks everything he sees. “Door” drips across his front door, “Tree” marks his tree, and his cat is clearly labeled “Cat”. Satisfied, the man says, “That should clear a few things up.”

Three Steps to Semantic Code

01 Start semantic

The first step to semantic, meaningful CSS is to start with semantic, meaningful markup. Classes are arbitrary, but HTML is not.

02 Coding Semantic

In HTML, every element has a very specific, agreed-upon meaning, and so do its attributes. Good markup is inherently expressive, descriptive, semantic, and meaningful.

03 Designing Semantics

If and when the semantics of HTML5 fall short, we have ARIA, specifically designed to fill in the gaps.

The Patron Saints of Web Design

ponyo
Ponyo
kodama
Kodama
noh_face
Noh Face
radio
Radio
soot_sprint
Soot Sprite
zeneba
Zeneba
note
Witch Note
mononoke
Mononoke
volucite
Volucite
totoro_gifts
Totoro Gifts
ohmu
Ohmu
calcifer
Calcifer
calcifer_demon
Calcifer Demon