Performance: Semantic vs non-semantic elements
MEDIUM IMPACT
This affects page rendering speed and accessibility, impacting how browsers and assistive technologies process content.
<header>Site Title</header> <nav>Menu</nav> <main>Content</main> <footer>Footer info</footer>
<div id="header">Site Title</div> <div id="nav">Menu</div> <div id="main">Content</div> <div id="footer">Footer info</div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Non-semantic <div> with ARIA roles | More DOM nodes with added attributes | Multiple reflows if roles added dynamically | Higher paint cost due to layout shifts | [X] Bad |
| Semantic elements like <header>, <nav> | Fewer DOM operations, native roles | Single reflow on load | Lower paint cost with stable layout | [OK] Good |