HTML Basics
HTML Paragraphs
The paragraph is the workhorse of web text. This page shows how the <p> tag works, how browsers treat spaces and line breaks, and how to control them.
What is an HTML Paragraph?
A paragraph is a block of text defined with the <p> tag. Browsers automatically add space above and below each paragraph, which separates blocks of text visually.
One thing surprises beginners: the browser collapses whitespace. Multiple spaces, tabs, or new lines in your source code are all displayed as a single space. To force a line break or extra space, you use specific tags.
Basic Usage
<p>This is the first paragraph.</p>
<p>This is the second paragraph.</p>Example: How Whitespace Collapses
<!DOCTYPE html>
<html>
<body>
<p>This text has many spaces,
but the browser shows it as single spaces
on one flowing line.</p>
</body>
</html>More Examples
<p>Roses are red,<br>
Violets are blue,<br>
HTML is fun,<br>
And so are you.</p><pre>
This text keeps
its spaces
and line breaks
exactly as typed.
</pre>Text Spacing Tags
| Tag | Effect |
|---|---|
| <p> | Creates a paragraph with space above and below. |
| <br> | Inserts a single line break inside text. |
| <hr> | Draws a horizontal divider line. |
| <pre> | Preserves whitespace and line breaks exactly. |
Use <br> sparingly — only for genuine line breaks like poems or addresses. For spacing between blocks, use separate paragraphs or CSS margins instead.
You cannot fix layout with lots of blank lines or spaces in the source. The browser ignores them. Use CSS for spacing and alignment.
Key Takeaways
- The <p> tag defines a paragraph of text.
- Browsers collapse multiple spaces and line breaks into one space.
- Use <br> for a single line break and <pre> to keep exact spacing.
- Control real spacing with CSS, not blank lines.
