Hi, this is my personal styleguide. I use it to share how I like to code. You can fork it on GitHub or ask me questions on Twitter.
A declaration block in CSS refers to an entire block of CSS between the < >brackets. For example:
.header font-weight: bold; >
A declaration refers to one property: value; line.
font-weight: bold;
Here's some rules that focus on declaration blocks and lines.
.head
.head display: block; border: 1px solid #a80; >
Separate blocks of declarations by an empty line. Except for declarations that are single lines.
.col-1 < width: 50%; >.col-2
.col-1 width: 50%; > .col-2 width: 25%; >
Every property within a rule set should be on it's own line. This helps with error detection when processing your CSS in a CI setup.
You can break the one line rule when a ruleset contains one declaration, it should be placed on a single line.
.call-to-action < width: 100px; height: 100px; >.email-link
.call-to-action width: 100px; height: 100px; > .email-link display: block; > .twitter-link display: inline; >
Whenever possible use the shorthand notation for properties rather than the full lines. For more reading I recommend this Mozilla article.
border-width: 1px; border-style: solid; border-color: #000;
border: 1px solid #000;
Find anything wrong with this guide? open an issue on GitHub.