Home / Learn HTML / HTML Paragraphs and Line Breaks

HTML Paragraphs and Line Breaks

Paragraphs hold your text. The browser ignores extra spaces and line breaks in the code, so you need the right tags.

Definition

The p element defines a paragraph. A browser always starts a paragraph on a new line and adds space above and below it. Paragraphs are the main building block of text on the web.

Important rules

Theory in plain words

Source code vs what the browser showsYou typeMany spacesLines in codeBlank linesBrowser showsOne spaceText flows togetherNo extra gap
Source code vs what the browser shows

What it is

The p element holds a paragraph of text. The br element makes a line break inside it.

Why we use it

Paragraphs are the main way to write readable text. Browsers add spacing and wrap lines for you.

How it works

Extra spaces and new lines in your code are collapsed to one space. To force a line break use br. To start new text use a new p.

Where it is used

  • Articles and descriptions
  • Poems and addresses (with br)
  • Any body text
A paragraphTry it Yourself
Two paragraphsTry it Yourself

Each paragraph gets space above and below.

Extra spaces are ignoredTry it Yourself

The browser squeezes them into one space.

Line break with brTry it Yourself

Use br for an address or a poem, not to make space.

Keep spaces with preTry it Yourself

pre shows text exactly as typed.

PoemTry it Yourself
AddressTry it Yourself
Align textTry it Yourself
Wide space with entityTry it Yourself

  is a space the browser will not squeeze.

Line height and sizeTry it Yourself
Indent first lineTry it Yourself
Wrap a long wordTry it Yourself
Careful:Do not press the Enter key many times to make blank space. Use CSS margin instead.

Quick quiz

1. Which tag makes a line break?

2. Extra spaces in HTML code are

3. Which tag keeps spaces exactly?

Common questions

Which tag makes a line break?

<br>. br breaks the line.

Which tag keeps spaces exactly?

<pre>. pre shows text as typed.

My notes
Ask a question about this lesson