General Rules
Leave a space between comment markers
/* Like this */
Make sure rules are in alphabetical order
.like-this { background-color: color: padding: }
/* Like this */
Make sure rules are in alphabetical order
.like-this { background-color: color: padding: }
// Bad, this is vague and easily confused
.btn-1{ rule; }
// Good
.blurb { .blurb--icon {... .blurb--img {... }
// Bad, this is vague and easily confused
.btn-1 { rule; }
// Good
.primary-button { rule; }
.secondary-button { rule;
// Bad
#needs-space{ rule; }
// Good
#has-space { rule; }
// Bad
#needs-new-line { rule; }
// Good
#has-new-line {
rule;
}
// Bad. DO NOT use selectors like this. It's very inefficient and leads to styles being
// applied to elements that they shouldn't, requiring unnecessary overrides.
// Good
.li-class { rule; }
// Bad. Chaining many selectors leads to confusing, inefficient CSS.
.first { .first-child {
.second-child {
.third-child {
// Good, avoid chaining, only chain semantically grouped selectors if necessary .first { ... .first--child {