Aral Code

Text Lesson 7 of 42

HTML Paragraphs, Line Breaks and Preformatted Text

Learn how to write paragraphs with the p element, when to use br for line breaks, and how pre keeps spaces for poems and code.

Most of what people read on a web page is in paragraphs. In this lesson you'll learn how the <p> element works, how to break a line without starting a new paragraph, and how to keep your spacing exactly as you typed it.

The paragraph element

A paragraph starts with <p> and ends with </p>. Browsers add some space above and below each paragraph automatically, so they don't stick together.

Example Two paragraphs
<p>Every year, our school holds a Nutrition Month program in July. Students prepare healthy Filipino dishes like ginisang monggo and tinolang manok.</p>
<p>This year, the Grade 9 classes will also have a poster-making contest about eating vegetables.</p>

Reminder: the browser ignores extra spaces and Enters

You learned this in the structure lesson, but it's worth repeating because it confuses many students. However you arrange the text in your code, the browser joins it into one flowing paragraph:

Example Line breaks in the code are ignored
<p>
  Bahay Kubo, kahit munti,
  ang halaman doon
  ay sari-sari.
</p>

The song lyrics appear in one line, not three. To fix that, we need line breaks.

Line breaks with br

<br> forces the text to continue on the next line, inside the same paragraph. It is an empty element, so there's no closing tag.

Example Using br for lyrics and addresses
<p>
  Bahay Kubo, kahit munti,<br>
  ang halaman doon<br>
  ay sari-sari.
</p>

<p>
  Juan Dela Cruz<br>
  123 Mabini Street, Brgy. Poblacion<br>
  Malolos, Bulacan 3000
</p>

When to use br — and when not to

  • Good uses: addresses, poems, song lyrics, signatures — places where the line break is part of the content.
  • Bad use: pressing <br><br><br> to create space between sections. That's what separate paragraphs and CSS margins are for.

Preformatted text with pre

What if you want the browser to show your spaces and line breaks exactly as you typed them? Use <pre> (preformatted). It also uses a monospace font where every letter has the same width, which is great for code, ASCII art and aligned text.

Example pre keeps spacing
<pre>
  Item            Price
  -----------     -------
  Pandesal x10    ₱ 30.00
  Kape 3-in-1     ₱ 10.00
  Itlog x2        ₱ 18.00
  -----------     -------
  TOTAL           ₱ 58.00
</pre>

Without <pre>, all those spaces would collapse and the columns would not line up.

Long text and readability

A few tips that make paragraphs easier to read on any screen:

  • Keep paragraphs short. Three to five sentences is plenty on the web. People read on small phone screens.
  • One idea per paragraph. When the topic changes, start a new one.
  • Don't type in ALL CAPS. It's harder to read and feels like shouting.

Special case: you cannot put block elements inside p

A paragraph can contain text and inline elements like <strong>, <em> and <a>. It cannot contain block elements like headings, lists, tables or other paragraphs. If you try, the browser closes the paragraph early on its own, which can cause strange spacing.

<!-- Wrong: a list inside a paragraph -->
<p>Bring these:
  <ul><li>Pencil</li><li>Eraser</li></ul>
</p>

<!-- Right: paragraph, then the list -->
<p>Bring these:</p>
<ul><li>Pencil</li><li>Eraser</li></ul>

Quick Quiz

Check what you learned. Walang grade ito, practice lang. 🙂

1. What does <br> do?
2. Which element keeps spaces and line breaks exactly as typed?
3. What is a good use of <br>?
4. Can you put a <ul> list inside a <p>?

By Sir Reyel · Last updated 2026-12-04