Multi-Single-Line CSS

When people argue over how to orga­nize their CSS, the debate usu­ally comes down to two approaches: multi-line vs. single-line. Obviously both have their ben­e­fits and draw­backs, but they aren’t the only two viable options. One tech­nique I’ve been using more and more recently is a com­bi­na­tion of the two styles.

For lack of a fancy name I just call it multi-single-line CSS. The premise is pretty simple: main­tain the leg­i­bility of multi-line CSS while short­ening total file length. The way it works is that you group sim­ilar attrib­utes (for example width and height) onto a single line. In doing so, you’re saving space while making con­nec­tions between attrib­utes that are often ref­er­enced together.

The different coding styles

As you can see, it’s a nice middle ground between long and short. Here are a couple more exam­ples pulled from my CSS file:

Some more examples of multi-single-line CSS

Hopefully you find it useful, and if you have any sug­ges­tions to make it better I’d love to hear ‘em!