Performance: Line breaks and horizontal rules
This concept affects page rendering speed and visual stability by how the browser processes line breaks and horizontal rules in the layout.
<p>Paragraph 1</p><p style="margin-top:2rem;">Paragraph 2</p><hr style="margin-top:2rem;">
<div>Paragraph 1</div><br><br><br><div>Paragraph 2</div><hr><hr><hr>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Multiple <br> and <hr> tags | Many extra nodes | Multiple reflows per tag | High paint cost due to layout thrashing | [X] Bad |
| Single <hr> with CSS spacing | Minimal nodes | Single reflow | Low paint cost | [OK] Good |
<br> tag do in HTML?<p>Hello<br>World<hr><p>Goodbye</p>
<p>Line one<br><hr>Line two</p>
First paragraph.
Second paragraph.
uses <br> outside paragraphs which is invalid.First paragraph.
Second paragraph.
misses blank line.First paragraph.
<br>
Second paragraph.
uses literal <br> text, not tag.First paragraph.
Second paragraph.
correctly uses a paragraph with <br> for spacing and <hr> between paragraphs.Pass the test and this pattern moves unknown