3 min read · Free · No login needed
The <p> tag defines a paragraph. Browsers automatically add a blank line before and after each paragraph, so your text stays readable without you adding space yourself.
This surprises every beginner: in HTML, extra spaces and line breaks in your code are ignored. If you type ten spaces, the browser shows one. If you press Enter three times, the browser shows no line break at all. The browser only cares about the tags, not about how you formatted the source code.
When you want a line break without starting a new paragraph — for example, in an address or a poem — use <br>. It is an empty element, so it has no closing tag.
Sometimes you want the browser to keep your spaces and line breaks exactly as typed — for example, in a piece of code. The <pre> tag does that. Everything inside it is shown in a fixed-width font, exactly as you wrote it.
<br> tags in a row to create space between paragraphs. Use a new <p> and let CSS control the spacing — it is cleaner and easier to change later.A paragraph, <p>, is a block of text about one idea. Browsers add a little space before and after each paragraph automatically, so two paragraphs are always separated by a blank line. A page is mostly paragraphs — they are the most used element in HTML.
| Tag | Value | Description |
|---|---|---|
<p> | text | A normal paragraph. |
<br> | — | A line break inside a paragraph. It has no end tag. |
<hr> | — | A horizontal line that separates one topic from another. |
<pre> | text | Preformatted text — spaces and line breaks are kept exactly as typed. |
Compare these two. In the first, the extra spaces and line breaks disappear. In the second, <pre> keeps everything exactly as you typed it:
<p>Hello world. This is one line.</p> <pre>Hello world. This is one line.</pre>
<br> five times to make a gap. Use CSS spacing instead, like style="margin-bottom: 20px;". It is cleaner and much easier to change later.<br><br><br> to make space between sections — that is the job of CSS margins.<p> — paragraphs can only hold text and inline elements.<pre> for normal text — it uses a fixed-width font and is meant for code, not articles.<!DOCTYPE html>, <html>, <head> and <title>Paragraphs</title> — the usual page skeleton. The title shows on the browser tab.<p>This is a paragraph. Browsers add space around it automatically.</p> — the line break inside the code is ignored. The browser collapses it into a single space, so the whole text shows as one flowing paragraph.<p>First line<br>Second line</p> — the <br> is an empty element with no end tag. It breaks the line in the middle of the paragraph without starting a new one.<pre> ... </pre> — preformatted text. Unlike a normal paragraph, it keeps every space and every line break exactly as typed, so "Line two (spaces kept)" keeps its extra spaces.<!DOCTYPE html>
<html>
<head>
<title>Paragraphs</title>
</head>
<body>
<p>This is a paragraph. Browsers add space
around it automatically.</p>
<p>First line<br>Second line</p>
<pre>
Line one
Line two (spaces kept)
Line three
</pre>
</body>
</html>
Change the code below and press Run to see the result instantly. No file to save, no login needed.
The questions learners ask most about this lesson — read the question, then open it to see the answer.
It defines a paragraph. Browsers automatically add a blank line before and after each paragraph.
Browsers collapse extra spaces, tabs, and new lines in normal text into a single space. Only tags change the layout.
Use the pre tag. Everything inside it is shown in a fixed-width font, exactly as you wrote it.
AI can write code for you, but it cannot think for you. When you learn HTML yourself, your brain builds the real skill: you understand why a page looks the way it does, you can fix it when it breaks, and you can answer it in an exam or an interview without help. That is the skill that gets you a job — not a copied answer.
Finish all 35 lessons, pass the test (80%), pay ₹10 and get your certificate.
Take the testPrefer watching? Video courses teach the same topics step by step.
Free tutorials teach you the basics. Our paid courses add live projects, mentorship and a certificate.
Browse all coursesAsk about courses, website & more
Request human callback:
Please log in to download. You will stay on this page after logging in!
New here? Register now →