The official book of California Stylesheets

YOU SUCK AT CSS

(and that's okay)

It's a book about writing CSS.
And not writing CSS.

You suck at naming things

The primary purpose of CSS is angering the British.

I'm an American. I go to all the meetings. This is our big secret. I'm selling it in this book.

Please don't tell any of your American friends.

In particular, we want to anger the redcoats by making them type "color" over and over. We like to remove letters from their words, especially U. We think it's hilarios.

Having said that, here's the point: The things you type over and over really matter. So they should have good names.

Not only is naming things a hard problem, but it's something you have to do up front, when you don't know anything. Outsource and export as much of this as you can. This is part of the 95%.

Most of the CSS you stress over should be in IDs. It should be specialized design touches. Cool stuff. Elements that stand out. Stuff that doesn’t exist anywhere else. Stuff that makes the user feel special and unique.

You do write classes too in any new project, but it shouldn't be most of what you do, because of the inherent nature of the thing. Classes are used over and over, so they need to be written less. This makes sense, I promise.

An obfuscated class name isn’t good for anyone. Stop sending that stuff to your users. If you don’t know what this means then you probably don’t need to worry about it.

Dashes and underscores are great for separating words. Don’t use them up front for weird conceptual namespacing. Nothing makes the next developer want to work with your markup less than weird conceptual namespacing markers. They already don’t want to write CSS. Don’t make it even worse.

Finally: Abstract name sets are fine for interaction elements. Name them after cities you like. Or models of car. Consistency is generally more important than accuracy, especially for naming arbitrary chunks of UI.

Fix it with CASS

CASS gives you a whole bunch of really simple CSS class names to use. It uses only full words with no abbreviations or numerals. There are no naming convention prefixes. It uses dashes to separate words, not underscores.

CASS isn’t designed to be written as much as it’s designed to be read. That’s why naming things is important-- not for you but for the next person to read what you wrote.

But also: For you. Nothing makes for worse past-self cringe than giving things bad names and then having to deal with it later. Well, okay, nothing outside of middle school.


Next Chapter: Documentation »

Like the book? Buy it over on Gumroad.

Pay what you want!

The Gumroad version contains a secret chapter that spills the dirt on CSS preprocessors, a tech CASS no longer uses.

California Stylesheets is the awesome CSS file/framework referenced in the book. Get your own California Stylesheet here.

Go to CASS