Open In App

How to define a paragraph in HTML?

Last Updated : 25 Jun, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

The <p> tag in HTML defines the paragraph. These have both opening and closing tags.

Anything written within <p> and </p> is treated as paragraph content. Most browsers read a line as a paragraph even if we don’t use the closing tag i.e. </p> but this may raise unexpected results. Therefore, it is good practice to use the closing tag.

Syntax:

<p> Content... </p>

Example 1: The example below shows the paragraph in HTML5.

html
<!DOCTYPE html>
<html lang="en">

<head>
    <title>
        A paragraph
    </title>
</head>

<body>
    <h2>
        Defining a paragraph
    </h2>
    <p>
        A Computer Science
        portal for geeks.
    </p>

    <p>
        It contains well written,
        well thought articles.
    </p>
</body>

</html>

Output:

paragrapghtag
Output

Example 2: The example below shows the paragraph in HTML5.

html
<!DOCTYPE html>
<html lang="en">

<head>
    <title>
        Define a paragraph
    </title>
</head>

<body>
    <h2>
        Define a paragraph
    </h2>
    <p>
        This paragraph has multiple
        lines. But HTML reduces them
        to a single line, omitting
        the carriage return we have used.
    </p>

    <p>
        This paragraph has multiple
        spaces. But HTML reduces them
        all to a single space, omitting
        the extra spaces and line
        we have used.
    </p>
</body>

</html>

Output:

paragrapghtagf
Output

Next Article

Similar Reads