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
- HTML ignores extra spaces and line breaks in your source code. Ten spaces look like one, and pressing Enter in the editor does not create a new line on screen.
- To start a new paragraph use another
p. To break a line inside a paragraph usebr. To keep exact spacing usepre. - Do not use empty paragraphs or many
brtags to create space. Use the CSSmarginproperty. - A
pmay contain only inline content (text, links, strong...). Block elements likedivor anotherpend it automatically.
Theory in plain words
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
Each paragraph gets space above and below.
The browser squeezes them into one space.
Use br for an address or a poem, not to make space.
pre shows text exactly as typed.
is a space the browser will not squeeze.
Quick quiz
1. Which tag makes a line break?
br breaks the line.
2. Extra spaces in HTML code are
Use or pre to keep them.
3. Which tag keeps spaces exactly?
pre shows text as typed.
Common questions
Which tag makes a line break?
<br>. br breaks the line.
Which tag keeps spaces exactly?
<pre>. pre shows text as typed.