Lesson 10 of 51 · Module 2, lesson 4 of 9 · 4 min
Paragraphs, line breaks and white space
Write paragraphs, and understand why the browser ignores extra spaces and line breaks in your code.
What you'll learn
- How to write paragraphs with
<p>- Why the browser ignores extra spaces and line breaks in your code
- When to use a line break
<br>and a dividing line<hr>
Why this matters
Most of the text on the web is paragraphs. The browser has one rule about them that surprises every beginner: pressing Enter in your code does not start a new line on the page. Once you know this rule, your pages will look the way you expect.
Paragraphs
Put each paragraph inside <p> and </p>. The browser places each one on a new line, with space above and below.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My day</title>
</head>
<body>
<h1>My day</h1>
<p>I woke up early and made tea.</p>
<p>After breakfast, I studied HTML for one hour.</p>
<p>In the evening,
I cooked tomato soup
for my family.</p>
</body>
</html>
What you'll see: three separate paragraphs. The third one is on one line, with single spaces — even though the code spreads it over three lines with many spaces.
The white-space rule
The browser treats every group of spaces, tabs and line breaks inside text as one single space. This is called collapsing white space.
This is useful: you can arrange your code neatly, with indentation, without changing the page. But it also means you cannot make space or new lines by pressing the space bar or Enter. Instead:
- For a new paragraph, use a new
<p>. - For a new line inside a paragraph, use
<br>. - For more space between things, use CSS (later).
Line breaks: <br>
<br> means line break. It is a void element: no content, no closing tag. Use it only when the line break is part of the content itself — for example, an address or a poem.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contact</title>
</head>
<body>
<h1>Our kitchen</h1>
<p>
Green Street 12<br>
Riverside<br>
Postcode 40100
</p>
</body>
</html>
What you'll see: the address on three lines, inside one paragraph.
Dividing lines: <hr>
<hr> means a thematic break: a change of topic inside the page, such as between two stories. Browsers draw it as a horizontal line. It is also a void element.
<p>That was the soup recipe.</p>
<hr>
<p>Now, a recipe for fresh bread.</p>
Try it yourself
- Select the "My day" example and choose Try it.
- Add many spaces between two words in a paragraph. Watch the preview: nothing changes.
- Put a
<br>in the middle of a sentence and see the line break. - Add an
<hr>between the second and third paragraph.
Common mistakes
- Pressing Enter and expecting a new line. The browser collapses it into a space. Fix: use a new
<p>, or<br>for a line inside a paragraph. - Using many
<br>to make space, such as<br><br><br>. It creates empty lines that screen readers may announce, and it is hard to change later. Fix: use separate paragraphs now; control spacing with CSS later. - Putting a heading or another paragraph inside
<p>. A paragraph may contain only text and small elements like<strong>. The browser ends the paragraph early, and your page looks different from your code. Fix: close the<p>before the heading.
Check yourself
- In your code, a sentence has five spaces between two words. How many spaces appear on the page?
- Which element makes a new line inside a paragraph?
- Is
<br><br>a good way to add space between paragraphs?
Answers
- One.
<br>.- No. Use separate
<p>elements, and CSS for spacing.
Next: your paragraphs contain words that matter more than others. The next lesson shows how to mark text as important or emphasised — and what that really means.


