What are HTML Paragraphs


Paragraphs in HTML are used to display text elements on a web page. In HTML paragraphs are defined using <p> tag.

HTML Paragraphs

Paragraphs in HTML

HTML paragraphs are defined using <p> tag. The text enclosed in between <p> and </p> acts as a paragraph.

Most browsers recognize a line as a paragraph even if we forget using the closing </p> tag as the earlier versions of the HTML used to support it.

Sample Code

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


This is a paragraph.

This is another paragraph.

From the above example you could notice that by default a line space is added before and after a paragraph. This is achieved by the browser by setting up the top and bottom margins automatically for every paragraph.

Properties of Paragraphs

HTML Line Break using <br>

As discussed earlier in the properties of paragraphs in HTML, line breaks can be achieved by using the <br> tag.

Sample Code

<p>This is<br>a paragraph<br>with line breaks.</p>


This is
a paragraph
with line breaks.

Note that the <br> tag is an empty tag which means, it doesn’t an end tag.

HTML Preformatted Text using <pre>

Preformatted text in HTML is defined by the <pre> tag. The text enclosed between a <pre> and the closing </pre> tag is usually displayed in a fixed-width/ monospaced font such as Courier New or Consolas and also maintains/ preserves both spaces and line breaks.

Hence, whatever you write inside the <pre> and </pre> tags will remain the same with spaces, line breaks and everything.

Sample Code

This is line 1
This is line 2 
This is line 3


This is line 1
This is line 2 
This is line 3

Text Alignment

Text alignment is achieved in HTML using the align attribute. It allows us to adjust text horizontally left, right or center.

Sample Code

<p align="left">This line is aligned left</p> 
<p align="right">This line is aligned right</p> 
<p align="center">This is aligned center</p> 


This line is aligned left

This line is aligned right

This line is aligned center

Foot Notes