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: css
cssscssnestingstructure
Nest SCSS selectors to follow the component's markup hierarchy
Use shallow SCSS nesting for meaningful ancestor-dependent styles, without mirroring incidental DOM structure.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codescss
| 1 | .container { } |
| 2 | .filterLabel { } // sibling, but it's a child in markup |
Explanation (EN)
A truly ancestor-dependent style can be hard to identify when its qualifier is scattered.
Objašnjenje (HR)
Good example
New codescss
| 1 | .container { |
| 2 | .filterLabel { } |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
Use shallow nesting to express an intentional ancestor-dependent variant or ownership boundary, checking compiled selectors and specificity.
Exceptions / Tradeoffs (EN)
Do not mirror every DOM wrapper; scoped component styles can remain flat. Coordinate this rule with the shallow-nesting rule by preserving only meaningful ancestry.