Rules Hub
Code Ruleset
← 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 ruleP2stack specificStack: SCSS/CSS
cssselectorsspecificitymaintainability
Avoid selectors that match all descendants of an element
Don't use broad child/descendant selectors (e.g. `.parent *`) that style everything inside; target specific classes to keep styles predictable.
PR: vinify-frontend · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codescss
| 1 | .wineDetails > * { |
| 2 | margin-bottom: 8px; |
| 3 | } |
Explanation (EN)
A broad child selector can style a newly added unrelated child accidentally.
Objašnjenje (HR)
Good example
New codescss
| 1 | .wineDetailsRow { |
| 2 | margin-bottom: 8px; |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
When only a known component part should receive a style, use its existing semantic class and preserve the intended child/descendant relationship.
Exceptions / Tradeoffs (EN)
Broad selectors can be intentional in a scoped reset or controlled content-layout primitive; do not add classes to every descendant without a reason.