Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
frontend ruleP2universalStack: SCSS
cssspecificityscssclean-code
Beat CSS specificity with a selector trick, not an extra wrapper div
To override a higher-specificity rule from a shared component, repeat a class in the selector (.modal.modal) rather than adding a wrapper element solely to win specificity.
PR: hegnar-zephr-components · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetsx
| 1 | // extra wrapper div added only so a descendant selector can win specificity |
| 2 | <div className={styles.wrapper}><Modal /></div> |
| 3 | // .wrapper section.modal.modal { width: 400px; } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codescss
| 1 | /* repeat the class to raise specificity without extra markup */ |
| 2 | .modal[class*='visible'].modal { |
| 3 | width: 400px; |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)