A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/html/html-p-align-attribute/ below:

HTML <p> align Attribute - GeeksforGeeks

HTML <p> align Attribute

Last Updated : 11 Jul, 2025

The align attribute in the HTML <p> tag is used to control the alignment of paragraph text. It allows you to align text to the left, center, or right of its container. This attribute helps in adjusting the text layout for better presentation and readability.

Syntax:

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

However, the align attribute for the <p> tag is deprecated in HTML5. Today, developers are encouraged to use CSS for text alignment to ensure proper styling and compatibility across modern web browsers.

Example 1: Aligning Paragraph Text to the Left (Deprecated)

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

index.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:

HTML <p> align Attribute

In this example:

Example 2: Aligning Paragraph Text to the Right (Deprecated)

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

index.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:

HTML <p> align Attribute

In this example:

Why Is the align Attribute Not the Best Option?

While the align attribute works, it's no longer the best way to control content alignment in modern HTML. Here’s why:

Note : 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.

Conclusion

The align attribute in the HTML <p> tag provides basic text alignment options like left, center, right, and justify. However, it is now considered deprecated in HTML5, as CSS offers more flexibility and control over text alignment and layout.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4