This is somewhat of a personal post. “Personal” in the sense that the information is very subjective and not objective. However, I will try and persuade you of my opinion.
“CSS declarations should be written on a single line.” — me
p {font-size: 1.8em; line-height: 1.5; color: #000; margin: 0 0 1.5em;}
…as opposed to:
p {
font-size: 1.8em;
line-height: 1.5;
color: #000;
margin: 0 0 1.5em;
}
Here’s why:
- Conventional indenting styles, such as K&R or BSD Kernal Normal Form are originally for scripting or compiled languages that can nest calls. CSS very, very rarely nests declarations.
- CSS documents get extremely long, extremely fast.
- When scanning or modifying CSS, you search by tag, class, or ID, not by style.
- It reduces document size.
I’ve been writing single-line CSS for the last three years, and I’ve found it to be amazingly easier to read, edit, scan, and teach. I suggest trying it.
Check out my CSS and tell me what you think.