- Mobile First approach is usualy the best choice.
- Always style by class name (never
idor tag name selectors). - Order your declarations as proposed in Idiomatic CSS.
- Make sure that your preferable solution meets desirable Browsers Support.
Exceptions
contentdeclaration should be on the first place in Declaration Order.
- Always use
.scsssyntax. - Use all the benefits - variables, nesting, mixins, build-in and custom functions, placeholders, etc. - to make code smarter, simpler, clearer and easier to maintain.
- Prefer
hexor other color model over named colors (#ff0000rather thanred).
- Use BEM in it's most popular Two Dashes style.
- 1 block per 1 file with corresponding name (e.g.
.cardblock in_card.scssfile). - Declare block name only once at top of the file. Use
$root/$thisvariable to reuse it. - Media Queries should be placed at the end, once for each block rather than independently for block elements.
Exceptions
- Using CSS resets / normalizers is allowed (yes, it's against BEM)
- We use No Naming style
syntax for "state modifiers" - (
.-is-*and.-has-*). - Styling
imgandsvgby tag name is allowed. Why? - In some cases (like using external component with imposed markup) it may be unavoidable to break BEM naming convention rules.
- CSS Specifications
- Idiomatic CSS by Nicolas Gallagher
- mobile-first responsive web design by Brad Frost
- Reasons not to use IDs in CSS by Claire Parker-Jones
- Sass documentation
- "7 Sass techniques to help you write better code" by Andrius Juskenas