Performance: Universal selector
MEDIUM IMPACT
The universal selector affects the style calculation and layout phases by applying styles to all elements, which can slow down rendering.
body, h1, p, ul, li { margin: 0; padding: 0; }* { margin: 0; padding: 0; }| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Universal selector (*) | All elements matched | Triggers reflow for all elements | High paint cost due to many styled nodes | [X] Bad |
| Specific element selectors | Only targeted elements matched | Reflow limited to fewer elements | Lower paint cost | [OK] Good |