HTML Paragraphs
Master this topic with zero to advance depth.
Expert Answer & Key Takeaways
Mastering HTML Paragraphs is essential for high-fidelity technical architecture and senior engineering roles in 2026.
HTML Paragraphs
The HTML
<p> element defines a paragraph. A paragraph always starts on a new line, and browsers automatically add some white space (a margin) before and after a paragraph.<p>This is a paragraph.</p>
<p>This is another paragraph.</p>HTML Display
You cannot be sure how HTML will be displayed. Large or small screens, and resized windows will create different results.
With HTML, you cannot change the display by adding extra spaces or extra lines in your HTML code. The browser will automatically remove any extra spaces and lines when the page is displayed:
<p>
This paragraph
contains a lot of lines
in the source code,
but the browser
ignores it.
</p>
<p>
This paragraph
contains a lot of spaces
in the source code,
but the browser
ignores it.
</p>HTML Line Breaks
The HTML
<br> element defines a line break. Use <br> if you want a line break (a new line) without starting a new paragraph:<p>This is<br>a paragraph<br>with line breaks.</p>The
<br> tag is an empty tag, which means that it has no end tag.The Poem Problem
This poem will display on only one line because the browser ignores the spaces and line breaks:
<p>
My Bonnie lies over the ocean.
My Bonnie lies over the sea.
My Bonnie lies over the ocean.
Oh, bring back my Bonnie to me.
</p>The HTML <pre> Element
The HTML
<pre> element defines preformatted text. The text inside a <pre> element is displayed in a fixed-width font (usually Courier), and it preserves both spaces and line breaks:<pre>
My Bonnie lies over the ocean.
My Bonnie lies over the sea.
My Bonnie lies over the ocean.
Oh, bring back my Bonnie to me.
</pre>💡 Interactive Task
Compare the difference between
<p> and <pre> by pasting the same poem into both tags in your editor. Notice how the browser 'cleans up' the text in the <p> tag but leaves the <pre> tag exactly as you wrote it!Interview Corner
❓ Interview Question
Q: How do I add multiple spaces between words in HTML?
A: The browser collapses multiple spaces into one. To force multiple spaces, you can use the entity
(non-breaking space) or use the <pre> tag which preserves formatting.❓ Interview Question
Q: What is the difference between
<p> and <br>?A: The
<p> tag is a block-level element used to define a new paragraph with vertical margins. The <br> tag is an inline element used only to force a simple line break without adding extra vertical space.❓ Interview Question
Q: When should I use the
<pre> tag?A: Use the
<pre> tag when the formatting (spaces/indentation) as written in the code is important, such as for displaying code snippets, poems, or ASCII art.Course4All Engineering Team
Verified ExpertFrontend Architects
Focused on accessibility, semantic structure, and modern SEO, our frontend team ensures the HTML/CSS curriculum meets 2026 professional standards.
Pattern: 2026 Ready
Updated: Weekly
Found an issue or have a suggestion?
Help us improve! Report bugs or suggest new features on our Telegram group.