|
10 | 10 | - Always prefer using a class over HTML tags (with some exceptions like CSS resets)
|
11 | 11 | - Don't use ids in selectors
|
12 | 12 | - `#header` is overly specific compared to, for example `.header` and is much harder to override
|
13 |
| - - Read more about the headaches associated with IDs in CSS here. |
| 13 | + - Read more about the headaches associated with IDs in CSS [here](http://csswizardry.com/2011/09/when-using-ids-can-be-a-pain-in-the-class/). |
14 | 14 | - Don’t nest more than 3 levels deep
|
15 | 15 | - Nesting selectors increases specificity, meaning that overriding any CSS set therein needs to be targeted with an even more specific selector. This quickly becomes a significant maintenance issue.
|
16 | 16 | - Avoid using nesting for anything other than pseudo selectors and state selectors.
|
|
20 | 20 | - If you must, leave a comment, and prioritise resolving specificity issues before resorting to `!important`.
|
21 | 21 | - `!important` greatly increases the power of a CSS rule, making it extremely tough to override in the future. It’s only possible to override with another `!important` rule later in the cascade.
|
22 | 22 | - Don’t use `margin-top`.
|
23 |
| - - Vertical margins collapse. Always prefer `padding-top` or`margin-bottom` on preceding elements |
| 23 | + - Vertical margins [collapse](https://developer.mozilla.org/en-US/docs/Web/CSS/margin_collapsing). Always prefer `padding-top` or`margin-bottom` on preceding elements |
24 | 24 | - Avoid shorthand properties (unless you really need them)
|
25 | 25 | - It can be tempting to use, for instance, `background: #fff` instead of `background-color: #fff`, but doing so overrides other values encapsulated by the shorthand property. (In this case, `background-image` and its associative properties are set to “none.”
|
26 | 26 | - This applies to all properties with a shorthand: border, margin, padding, font, etc.
|
@@ -234,7 +234,7 @@ Choose your modifiers wisely. These two rules have very different meaning:
|
234 | 234 |
|
235 | 235 | ## Selector Naming
|
236 | 236 |
|
237 |
| -- Try to use BEM-based naming for your class selectors |
| 237 | +- Try to use [BEM-based](http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/) naming for your class selectors |
238 | 238 | - When using modifier classes, always require the base/unmodified class is present
|
239 | 239 | - Use Sass’s nesting to manage BEM selectors like so:
|
240 | 240 | ```scss
|
@@ -262,7 +262,7 @@ There are a few reserved namespaces for classes to provide common and globally-a
|
262 | 262 | - `.o-` for CSS objects. Objects are usually common design patterns (like the Flag object). Modifying these classes could have severe knock-on effects.
|
263 | 263 | - `.c-` for CSS components. Components are designed pieces of UI—think buttons, inputs, modals, and banners.
|
264 | 264 | - `.u-` for helpers and utilities. Utility classes are usually single-purpose and have high priority. Things like floating elements, trimming margins, etc.
|
265 |
| -- `.is-, .has-` for stateful classes, a la SMACSS. Use these classes for temporary, optional, or short-lived states and styles. |
| 265 | +- `.is-, .has-` for stateful classes, a la [SMACSS](https://smacss.com/book/type-state). Use these classes for temporary, optional, or short-lived states and styles. |
266 | 266 | - `._` for hacks. Classes with a hack namespace should be used when you need to force a style with `!important` or increasing specificity, should be temporary, and should not be bound onto.
|
267 | 267 | - `.t-` for theme classes. Pages with unique styles or overrides for any objects or components should make use of theme classes.
|
268 | 268 |
|
|
0 commit comments