Paragraph


Paragraph

The paragraph tag is used to define a paragraph on a web page. Empty line is added before and after the paragraph tag by the browsers.

Syntax

< p >Content to be displayed< /p >

All the extra spaces and lines are removed by the browsers and the content is displayed. Hr tag is used to draw a horizontal line between 2 lines or 2 paragraphs. It is an empty element that means it doesn’t require a closing tag.

<p> tag:

A paragraph is defined by the HTML <p> tag. Both closing and opening tags are present for it. As a result, anything between <p> and </p> is considered as a paragraph. Even if we don't use the closing tag, </p>, most browsers perceive a line as a paragraph, which can lead to unexpected consequences. As a result, it is both a good convention and a requirement that we utilise the closing tag.

When we examine the webpage, we notice that a few spaces have been inserted before and after each paragraph. HTML does this by default. Here are a few key properties of the paragraph tag:

  • As previously stated, the p>tag automatically adds space before and after any paragraph, which is essentially browser margins.
  • When a user adds numerous spaces, the browser condenses them into one.
  • When a user adds numerous lines, the browser merges them into one.

All the extra spaces and lines are removed by the browsers and the content is displayed.

Hr tag is used to draw a horizontal line between 2 lines or 2 paragraphs. It is an empty element that means it doesn’t require a closing tag.

Example No.1:

<html> <body> <p> Knowledge2life is best learning website. </p> </body> </html>

OUTPUT:

Knowledge2life is best learning website.

Example No.2:

<html> <body> <p> Knowledge2life </p> <p> Knowledge2life is best learning website. </p> </body> </html>

OUTPUT:

Knowledge2life
Knowledge2life is best learning website.