:
in property declarations.{
in rule declarations.#000
unless using rgba()
in raw CSS (the SCSS rgba()
function is overloaded to accept hex colors, as in rgba(#000, .5)
).//
for comment blocks (instead of /* */
).margin: 0;
instead of margin: 0px;
.When and when not to create:
As a rule of thumb, avoid unnecessary nesting in SCSS. At most, aim for three levels. If you cannot help it, step back and rethink your overall strategy (either the specificity needed, or the layout of the nesting).
Here are some good examples that apply the above guidelines:
// Example of good basic formatting practices.styleguide-format {color: #000;background-color: rgba(0, 0, 0, .5);border: 1px solid #0f0;}// Example of individual selectors getting their own lines (for error reporting).multiple,.classes,.get-new-lines {display: block;}// Avoid unnecessary shorthand declarations.not-so-good {margin: 0 0 20px;}.good {margin-bottom: 20px;}