Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Beat CSS specificity with a selector trick, not an extra wrapper div
Avoid adding DOM wrappers solely for CSS specificity; prefer a supported styling hook or a small verified selector override.
Bad example
| 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)
Extra DOM solely for cascade precedence couples markup to an incidental selector battle.
Objašnjenje (HR)
Good example
| 1 | /* repeat the class to raise specificity without extra markup */ |
| 2 | .modal[class*='visible'].modal { |
| 3 | width: 400px; |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
When a wrapper exists solely to win CSS specificity, first inspect supported style hooks, layer/order control and the smallest selector that expresses the override.
Exceptions / Tradeoffs (EN)
A repeated class is a valid specificity tool but should be a targeted compatibility measure; do not substitute broad substring selectors or remove a wrapper needed for layout/semantics.