HTML Paragraph (original) (raw)

Last Updated : 27 Feb, 2025

An HTML paragraph is a block of text used to structure and organize content on a webpage. It is one of the most commonly used elements in HTML and is defined using the

tag. Paragraphs help break down text into readable sections, making it easier for users to consume information.

**Example:

html `

This is the first paragraph.

This is the second paragraph.

This is the third paragraph.

`

**Closing the HTML Paragraph Element

In HTML 4 and earlier versions, closing the

tag wasn't mandatory. However, in HTML5, it is best practice to close the

tag to avoid rendering issues.

**Example:

html `

This is a paragraph without a closing tag

This is another paragraph.

This is a properly closed paragraph.

`

**In this Example:

**Line Breaks in Paragraph

In HTML, line breaks within a paragraph can be achieved using the
tag. This tag inserts a single line break, allowing text to continue on the next line within the same paragraph without creating a new paragraph block.

**Example:

html `

This is the first
paragraph
with two line breaks.

This is the second
paragraph
with three line breaks.

`

**In this Example:

**Comments in HTML

In HTML, comments are used to add notes or annotations that are not displayed in the web browser. They are enclosed within and ignored during rendering.

**Example:

html `

This is a paragraph.

    <!--
This is a multiline comment
used to provide detailed explanations
   -->
    <p>This is another paragraph.</p>
</body>

`

**In this Example:

**The PRE Element in HTML

The

 element
in HTML is used to define preformatted text, preserving both spaces and line breaks. It's commonly used for displaying code snippets or text with a specific formatting that needs to be maintained.

**Example:

html `

Twinkle Twinkle Little Star

  
     Twinkle, twinkle, little star  
    How I wonder what you are  
    Up above the world so high  
    Like a diamond in the sky  
        

`

**In this Example:

Best Practices for Using HTML Paragraphs