Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Include the base state in a grouped pseudo-class selector list
When several pseudo-class states share styling, include `&` in the comma-grouped selector list rather than duplicating the same rule for the base element separately.
Bad example
| 1 | .link { color: red; } |
| 2 | .link:hover, .link:focus { color: red; } |
Explanation (EN)
Duplicated state declarations can drift even though their intended value is identical.
Objašnjenje (HR)
Good example
| 1 | .link { |
| 2 | &, &:hover, &:focus { color: red; } |
| 3 | } |
Explanation (EN)
The group preserves exactly the base, hover and focus selectors from the original example.
Objašnjenje (HR)
Notes (EN)
When the exact same declarations apply to a base selector and specified states, group those same selectors using syntax supported by the build/browser baseline.
Exceptions / Tradeoffs (EN)
Do not add active/visited states that were absent before; grouping can change cascade position and specificity interactions with intervening rules.