HTML CSS Bootstrap JavaScript jQuery MySQL PHP Data Mining

Paragraphs

A paragraph is a block of text. In HTML, paragraphs are defined using the <p> tag. Browsers automatically add space (margin) before and after each paragraph.


The <p> Tag

Use the <p> element to define a paragraph:

<p>This is a paragraph.</p>
<p>This is another paragraph.</p>

Browser output:

This is a paragraph.

This is another paragraph.


HTML and Whitespace

Browsers ignore extra spaces and extra lines in HTML source code. Multiple spaces are displayed as a single space:

<p>This paragraph
    has       lots of
                extra spaces.</p>

Browser output:

This paragraph has lots of extra spaces.

Note: You cannot change the display by adding extra spaces or blank lines in your HTML code. The browser will remove them.

HTML Line Breaks — <br>

The <br> tag inserts a single line break without starting a new paragraph. It is an empty element — no closing tag needed:

<p>
    This is line one.<br>
    This is line two.<br>
    This is line three.
</p>

Browser output:

This is line one.
This is line two.
This is line three.


HTML Horizontal Rule — <hr>

The <hr> tag defines a thematic break in content and is displayed as a horizontal line. It is also an empty element:

<h2>Section One</h2>
<p>Content of section one.</p>
<hr>
<h2>Section Two</h2>
<p>Content of section two.</p>

Browser output:

Section One

Content of section one.


Section Two

Content of section two.


Pre-formatted Text — <pre>

The <pre> element displays text with preserved whitespace and line breaks exactly as written in the HTML source. Text is shown in a fixed-width (monospace) font:

<pre>
    My name    is John.
    I    am    a developer.
    Line    one.
    Line    two.
</pre>

Browser output:

    My name    is John.
    I    am    a developer.
    Line    one.
    Line    two.
                                
Tip: Use <pre> when you need to display code, poetry, or any text where spacing and line breaks are part of the meaning.

Quick Reference

Tag Description
<p>Defines a paragraph — adds spacing above and below
<br>Inserts a single line break (empty element)
<hr>Horizontal dividing line (empty element)
<pre>Displays text with preserved spaces and line breaks