Open In App
Related Articles

HTML <p> align Attribute

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

The HTML <p> align Attribute is used to specify the alignment of paragraph text content. The align attribute in <p> aligns text horizontally.

CSS properties like ‘text-align’ offer precise alignment. It also determines paragraph alignment—left, right, center, or justified.

Note: This tag is Deprecated in HTML5.

Syntax:

<p align="left | right | center | justify">

Attribute Values:

Attributes Values

Description

left

It sets the text left-align. It is a default value.

right

It sets the text right-align.

center

It sets the text center-align.

justify

It stretch the text of paragraph to set the width of all lines equal.

Example:

In this example, we will see the implementation of the <p> align Attribute with an example.

html

<!DOCTYPE html>
<html>
  
<head>
    <title>
        HTML p align Attribute
    </title>
</head>
<style>
    body {
        font-size: 25px;
    }
</style>
  
<body>
    <h1 style="color: green;">
      GeeksforGeeks
      </h1>
  
    <h2 style="color: crimson;">
      HTML p align Attribute
      </h2>
  
    <p align="left">
        Left align content
    </p>
    <p align="center">
        center align content
    </p>
    <p align="right">
        Right align content
    </p>
</body>
  
</html>

                    

Output:

Screenshot-2023-12-14-115926

Output

Example:

In this example, we will see the implementation of <p> align tag justify with an example.

HTML

<!DOCTYPE html>
<html>
  
<head>
    <title>
        HTML p align Attribute
    </title>
</head>
<style>
    body {
        font-size: 25px;
    }
</style>
  
<body>
    <h1>
        <p align="justify" style="color: green;">
            GeeksforGeeks
        </p>
    </h1>
  
    <h2 style="color: crimson;">
        HTML p align Attribute
    </h2>
  
    <p align="left">
        Left align content
    </p>
    <p align="center">
        center align content
    </p>
    <p align="right">
        Right align content
    </p>
</body>
  
</html>

                    

Output:

Screenshot-2023-12-14-120404

Output

Supported Browsers:

  • Google Chrome 1 and above
  • Microsoft Edge 12 and above
  • Firefox 1 and above
  • Opera 15 and above
  • Safari 1 and above

HTML is the foundation of webpages, is used for webpage development by structuring websites and web apps.You can learn HTML from the ground up by following this HTML Tutorial and HTML Examples.



Last Updated : 22 Dec, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads