SA-21/06, C-11, Asapur, Varanasi, UP support@kamaldnp.com +91 8318013442
HTML
1. HTML Introduction: What is HTML? Learn with Examples 2. Best Free HTML Editors: Notepad to VS Code for Beginners 3. HTML Basic Structure: Doctype, Head, Body Explained 4. HTML Elements Explained: Tags, Content & Empty Elements 5. HTML Attributes List: href, src, alt, width, title & More 6. HTML Headings h1 to h6: Which Heading Tag to Use When 7. HTML Paragraphs: p Tag, br Line Breaks & pre Text 8. HTML Style Attribute: Colour, Font Size & Alignment 9. HTML Text Formatting Tags: bold, italic, mark & More 10. HTML Comments: How to Add Notes & Hide Code in HTML 11. HTML Colors: Names, HEX, RGB & HSL Colour Codes 12. HTML CSS: Inline, Internal & External Stylesheets 13. HTML Links: a Tag, href, New Tab & Email Links 14. HTML Images: img Tag, src, alt, Width & Formats 15. HTML Favicon: Create & Add a Browser Tab Icon 16. HTML Title Tag: How to Write a Good Page Title 17. HTML Tables: table, tr, th, td, colspan & rowspan 18. HTML Lists: ul, ol, dl & Nested Lists Explained 19. HTML Block vs Inline Elements: div, p, span Explained 20. HTML Div Tag: Group Content & Build Page Layouts 21. HTML Class Attribute: Style Many Elements at Once 22. HTML id Attribute: Unique IDs, Links, CSS & JavaScript 23. HTML Iframes: Embed YouTube, Maps & Pages in HTML 24. HTML JavaScript: script Tag, Clicks & First Example 25. HTML File Paths: Relative vs Absolute Paths Explained 26. HTML Head Element: title, meta, charset & viewport 27. HTML Layout: header, nav, main, footer Page Structure 28. HTML Responsive Design: Viewport, Images & Media Queries 29. Semantic HTML Tags: header, nav, main, article & footer 30. HTML Forms: input, label, select, checkbox & Submit 31. HTML Entities: & < > © with Examples 32. HTML Audio & Video Tags: controls, source & Fallback 33. HTML Accessibility: alt Text, Labels, Landmarks & ARIA 34. HTML Meta Tags & SEO: charset, viewport, OG Tags 35. HTML Quotations: blockquote, q, cite, abbr & address
Final Test — Certificate ₹10
Try this code live
Lesson 7 of 35

HTML Paragraphs: p Tag, br Line Breaks & pre Text

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.

Diagram — see how it fits together
Infographic: paragraphs and line breaks

Spaces and new lines are collapsed

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.

Line breaks — the br tag

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.

Preformatted text — the pre 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.

Tip: Do not use many <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.

What a paragraph is

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.

Useful tags for text

TagValueDescription
<p>textA 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>textPreformatted 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>
Note: The browser collapses all extra spaces, tabs, and new lines inside normal text into a single space. Pressing Enter ten times in your code changes nothing on the screen — only tags change the layout.
Tip: Do not press <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.

Common mistakes

  • Putting a whole page in one giant paragraph — one idea, one paragraph.
  • Using <br><br><br> to make space between sections — that is the job of CSS margins.
  • Putting a heading, a list, or a table inside a <p> — paragraphs can only hold text and inline elements.
  • Using <pre> for normal text — it uses a fixed-width font and is meant for code, not articles.

Example explained

  • <!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.

Example

Example
<!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>

Output

Output — how it looks in the browser
Output of HTML Paragraphs: p Tag, br Line Breaks & pre Text

Try it yourself — live editor

Change the code below and press Run to see the result instantly. No file to save, no login needed.

Result

Frequently asked questions

The questions learners ask most about this lesson — read the question, then open it to see the answer.

1. What does the p tag do?

It defines a paragraph. Browsers automatically add a blank line before and after each paragraph.

2. Why do my extra spaces and line breaks disappear?

Browsers collapse extra spaces, tabs, and new lines in normal text into a single space. Only tags change the layout.

3. How do I keep spaces and line breaks exactly as typed?

Use the pre tag. Everything inside it is shown in a fixed-width font, exactly as you wrote it.

Why learn this yourself — and not just ask AI?

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.

Get certified — just ₹10

Finish all 35 lessons, pass the test (80%), pay ₹10 and get your certificate.

Take the test

Prefer watching? Video courses teach the same topics step by step.

Go further with a full course

Free tutorials teach you the basics. Our paid courses add live projects, mentorship and a certificate.

Summer Industrial Training in MERN Stack 2026
₹3,000
View
Master Python + AI Skills in 30 Days
₹499
View
CapCut Mobile Video Editing Course Beginner to Advance
₹99
View
Browse all courses
HTML — Lessons
1. HTML Introduction: What is HTML? Learn with Examples 2. Best Free HTML Editors: Notepad to VS Code for Beginners 3. HTML Basic Structure: Doctype, Head, Body Explained 4. HTML Elements Explained: Tags, Content & Empty Elements 5. HTML Attributes List: href, src, alt, width, title & More 6. HTML Headings h1 to h6: Which Heading Tag to Use When 7. HTML Paragraphs: p Tag, br Line Breaks & pre Text 8. HTML Style Attribute: Colour, Font Size & Alignment 9. HTML Text Formatting Tags: bold, italic, mark & More 10. HTML Comments: How to Add Notes & Hide Code in HTML 11. HTML Colors: Names, HEX, RGB & HSL Colour Codes 12. HTML CSS: Inline, Internal & External Stylesheets 13. HTML Links: a Tag, href, New Tab & Email Links 14. HTML Images: img Tag, src, alt, Width & Formats 15. HTML Favicon: Create & Add a Browser Tab Icon 16. HTML Title Tag: How to Write a Good Page Title 17. HTML Tables: table, tr, th, td, colspan & rowspan 18. HTML Lists: ul, ol, dl & Nested Lists Explained 19. HTML Block vs Inline Elements: div, p, span Explained 20. HTML Div Tag: Group Content & Build Page Layouts 21. HTML Class Attribute: Style Many Elements at Once 22. HTML id Attribute: Unique IDs, Links, CSS & JavaScript 23. HTML Iframes: Embed YouTube, Maps & Pages in HTML 24. HTML JavaScript: script Tag, Clicks & First Example 25. HTML File Paths: Relative vs Absolute Paths Explained 26. HTML Head Element: title, meta, charset & viewport 27. HTML Layout: header, nav, main, footer Page Structure 28. HTML Responsive Design: Viewport, Images & Media Queries 29. Semantic HTML Tags: header, nav, main, article & footer 30. HTML Forms: input, label, select, checkbox & Submit 31. HTML Entities: & < > © with Examples 32. HTML Audio & Video Tags: controls, source & Fallback 33. HTML Accessibility: alt Text, Labels, Landmarks & ARIA 34. HTML Meta Tags & SEO: charset, viewport, OG Tags 35. HTML Quotations: blockquote, q, cite, abbr & address
Final Test — Certificate ₹10

🤖 KAMALDNP AI Assistant

Ask about courses, website & more

Hi! I'm KAMALDNP AI Assistant. Ask me about our courses, website features, or anything else! 😊
Please wait 5s...
🤖 KAMALDNP Assistant ✕

Request human callback:

🔐 Login Required
✕

Please log in to download. You will stay on this page after logging in!

New here? Register now →