HTML <p> Tag

The <p> defines a paragraph of text. It is a block-level element, it always start on a new line, and browsers automatically add margin before and after each paragraph. You can modify the margins using CSS margin property.

If you need to just to move text to a new line use the <br> tag.

Spaces between the opening <p> tag and its content are ignored by the browser. In order to set an indent, use the CSS property text-indent.

Syntax

Paragraphs are written between the opening (<p>) and the closing (</p>) tags. If the closing tag is omitted, it is considered that the end of the paragraph matches with the start of the next block-level element.

The <p> tag cannot contain tables and other block-level elements.

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <p>This is a paragraph</p>
  </body>
</html>

Attributes

Attribute Value Description
align right
left
justify
Defines the text alignment.
Not supported in HTML5

The <p> tag also supports the Global Attributes and the Event Attributes.

Using the CSS

To align a text in a paragraph, use the CSS property text-align, instead of the obsolete align tag.

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      div.paragraph {
        text-align: center;
      }
    </style>
  </head>
  <body>
    <h1>Title of the document</h1>
    <div class="paragraph">
      <p>The text alignment to the center is set with CSS property text-align</p>
    </div>
  </body>
</html>