Performance: Inline vs external precedence
MEDIUM IMPACT
This concept affects how quickly styles are applied and how the browser resolves conflicts between inline and external CSS, impacting rendering speed and visual stability.
/* external.css */ .my-text { color: red; font-size: 1.5rem; margin: 1rem; } <!-- HTML --> <div class="my-text">Hello</div>
<div style="color: red; font-size: 1.5rem; margin: 1rem;">Hello</div>| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Inline styles | No extra DOM nodes, but larger HTML | Triggers style recalculation during HTML parsing | Paint triggered after style application | [!] OK |
| External CSS | No extra DOM nodes, smaller HTML | Style recalculation after CSS load | Paint triggered after CSS applied | [OK] Good |