Performance: Paragraphs
Paragraphs affect the page's rendering speed and layout stability by adding block-level text content.
<p>First paragraph text.</p><p>Second paragraph text.</p>
<div>First paragraph text.</div><div>Second paragraph text.</div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Using <div> for paragraphs | Multiple block nodes | Multiple reflows if styled dynamically | Higher paint cost due to layout shifts | [X] Bad |
| Using semantic <p> tags | Multiple block nodes | Single reflow per paragraph block | Lower paint cost with stable layout | [OK] Good |
<p> tag is specifically designed to create paragraphs in HTML.<div> and <section> are for grouping content, <span> is inline, not for paragraphs.<p> and close with </p>.<p>Hello World</p> correctly opens and closes the paragraph tag. Options A and B have missing closing brackets, and C uses an invalid tag.tags properly with
[OK]<p>First paragraph.</p> <p>Second paragraph.</p>
<p> tag creates a block with space above and below, so paragraphs appear separated by blank lines.<p>This is a paragraph. <p>This is another paragraph.</p>
<p> tag is not closed before the second <p> starts.needs a closing
[OK]<p> tags.<em> tag is used inside the second paragraph to italicize text properly without breaking HTML rules.Pass the test and this pattern moves unknown