Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Group selectors or use a custom property for a shared CSS value
When the same value (height, color, size) is set on an element and a descendant, or repeated across rules, group the selectors with a comma (e.g. `&, .child { height: X }`) or extract a custom property, instead of writing the declaration twice.
Bad example
| 1 | &--most-traded { |
| 2 | height: rem-calc(468); |
| 3 | [data-millistream] { height: rem-calc(468); } |
| 4 | } |
Explanation (EN)
The same height value is written twice, so a change has to be made in two places.
Objašnjenje (HR)
Good example
| 1 | &--most-traded { |
| 2 | &, [data-millistream] { height: rem-calc(468); } |
| 3 | } |
Explanation (EN)
One declaration shared via a grouped selector (or a custom property if reused widely).
Objašnjenje (HR)
Notes (EN)
Applies to any value obviously shared between an element and its descendants or between sibling rules. A custom property is the better choice when the value is reused across many rules or breakpoints.
Exceptions / Tradeoffs (EN)
If grouping the selectors hurts readability or the values only coincidentally match, keep them separate.