|
| 1 | +# CSS Checklist |
| 2 | + |
| 3 | + |
| 4 | +## Syntax |
| 5 | + |
| 6 | +- [ ] Indents use soft tabs of 2 spaces. |
| 7 | +- [ ] When grouping selectors, each selector is on its own line. |
| 8 | +- [ ] There's one space before opening braces `{`. |
| 9 | +- [ ] Closing braces `}` of declaration blocks are on a new line. |
| 10 | +- [ ] There's one space after the colon `:` in each declaration. |
| 11 | +- [ ] Each declaration is on its own line ending with a semicolon `;`. |
| 12 | +- [ ] No spaces after commas in `rgb()`, `rgba()`, `hsl()`, `hsla()`, or `rect()` values. |
| 13 | + For example: `rgba(220,200,200,.3)` |
| 14 | +- [ ] No zeros `0` prefixing property values or color parameters. |
| 15 | + For example do: `.5` don't: `0.5`. |
| 16 | +- [ ] Hex values are lowercase and shorthand if possible ie: `#fff`. |
| 17 | +- [ ] No units on zero values for example: `margin: 0;`, not: `margin: 0px;`. |
| 18 | +- [ ] No trailing white spaces. |
| 19 | +- [ ] Single quotes are used rather than double for property values: |
| 20 | + ```css |
| 21 | + .primary-header { |
| 22 | + font-family: 'Open Sans', sans-serif; |
| 23 | + } |
| 24 | + ``` |
| 25 | +- [ ] All rules within rules are indented. For example: |
| 26 | + ```css |
| 27 | + @media screen and (min-width: 800px) { |
| 28 | + |
| 29 | + .masonry { |
| 30 | + column-count: 4; |
| 31 | + } |
| 32 | + |
| 33 | + } |
| 34 | + ``` |
| 35 | + |
| 36 | + |
| 37 | +## Naming |
| 38 | + |
| 39 | +- [ ] Consistent naming conventions are used throughout (see [CSS_architecture.md](https://github.com/jessicarush/css-notes/blob/master/CSS_architecture.md)). |
| 40 | +- [ ] Dashes are preferred over camelCase when naming and underscores used for BEM child elements only. For example: |
| 41 | + ```css |
| 42 | + .media-box {} |
| 43 | + .media-box__heading {} |
| 44 | + ``` |
| 45 | +- [ ] Selectors are only as specific as they need to be. |
| 46 | +- [ ] Selectors are not (or rarely) tag qualified. |
| 47 | +- [ ] Classes are used over generic element selectors. |
| 48 | +- [ ] ID selectors are not used. |
| 49 | +- [ ] The universal selector `*` is not used. |
| 50 | +- [ ] Classes used for JS hooks are named with a prefix: `js-` and are not used for styling purposes. |
| 51 | + |
| 52 | + |
| 53 | +## Document |
| 54 | + |
| 55 | +- [ ] Property declarations are alphabetical (except vendor prefixes which should come before the non-prefixed declaration). For example: |
| 56 | + ```css |
| 57 | + .media-box { |
| 58 | + background: #fff; |
| 59 | + border: 1px solid #000; |
| 60 | + -moz-border-radius: 3px; |
| 61 | + -webkit-border-radius: 3px; |
| 62 | + border-radius: 3px; |
| 63 | + padding: 10px; |
| 64 | + text-align: center; |
| 65 | + } |
| 66 | + ``` |
| 67 | +- [ ] Styles are commented where needed and appropriate. |
| 68 | +- [ ] Media queries are placed close to their relevant rule sets whenever possible. |
| 69 | +- [ ] White space is used consistently to separate sections of code. |
| 70 | +- [ ] Rules are separated with one blank line. |
| 71 | + |
| 72 | + |
| 73 | +## Declarations |
| 74 | + |
| 75 | +- [ ] Styles applied to `:hover` are also applied to `:focus`. |
| 76 | +- [ ] `font-size`s are declared using `rem` units. |
| 77 | +- [ ] `line-height`s are declared using `em` units. |
| 78 | +- [ ] `border: 0;` is used, rather than `border: none;`. |
| 79 | + |
| 80 | + |
| 81 | +## Validators |
| 82 | + |
| 83 | +- [ ] CSS validates against the [W3C CSS validator](https://jigsaw.w3.org/css-validator/). |
| 84 | +- [ ] CSS validates against [CSS Lint](http://csslint.net/). |
0 commit comments