Performance: Avoiding deep nesting
MEDIUM IMPACT
Deep CSS nesting affects how quickly browsers match styles to elements, impacting page rendering speed.
.nav-link { color: red; }
nav ul li a span strong em { color: red; }| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Deeply nested selector (e.g., nav ul li a span strong em) | High (many DOM levels checked) | 0 (no layout change) | Low | [X] Bad |
| Shallow class selector (e.g., .nav-link) | Low (direct match) | 0 | Low | [OK] Good |