Performance: Block-level elements
Block-level elements affect page layout and rendering speed by controlling how content stacks vertically and triggers layout calculations.
<section><p>Text</p></section>
<div><div><div><p>Text</p></div></div></div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Deeply nested block elements | High DOM depth | Multiple reflows | High paint cost | [X] Bad |
| Minimal block elements with semantic tags | Low DOM depth | Single reflow | Low paint cost | [OK] Good |
<div> is a block-level element, while <span>, <img>, and <a> are inline elements.<header> are block-level and create sections.<img>, <button>, and <label> are inline or replaced elements, not block-level.<div>First</div> <span>Second</span> <div>Third</div>
<div> is block-level (new line), <span> is inline (same line).<span>Line 1</span> <span>Line 2</span> <span>Line 3</span>
<span> is inline, so all text appears on the same line.<span> with <div> makes each text block-level, forcing new lines.<section>, <header>, <p>, and <footer> are all block-level and semantically correct for sections.<div><span>Title</span><span>Para 1</span><span>Para 2</span><span>End</span></div> uses inline <span> incorrectly; <section><div>Title</div><div>Para 1</div><div>Para 2</div><div>End</div></section> uses <div> but misses semantic tags; <article><header>Title</header><span>Para 1</span><span>Para 2</span><footer>End</footer></article> mixes block and inline incorrectly.Pass the test and this pattern moves unknown