Rules Hub
Code Ruleset
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)
Two copies of one shared dimension can drift when the design changes.
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)
Share a repeated CSS value only when the selectors express the same design constraint, preserving their specificity, cascade position and conditional scope.
Exceptions / Tradeoffs (EN)
If grouping the selectors hurts readability or the values only coincidentally match, keep them separate. A custom property introduces inheritance and runtime override behavior; a Sass variable or grouped selector may be more appropriate when that is not intended.