Open In App

Which HTML Attribute is used to justify the content ?

The HTML attribute is used to justify-content is the align attribute. The align attribute of <p> tag is used to justify the text on a web page. This can be done by assigning the value to the aligned attribute as justified. The justification of the text aligns the text in such a way that it occupies equal horizontal space from both the left and right margins of a web page improving its appearance.

Note: The align attribute is deprecated in HTML5, and styles should be used via CSS for better practices.

Syntax:

<p align="justify">

Example 1:

<!DOCTYPE html>
<html>

<head>
    <title>Not Justified</title>
</head>

<body>
    <h3>The content is not justified</h3>

    <p>
        Welcome to Geeks for Geeks. It is a 
        computer science portal for geeks.
        It contains well written, well 
        thought articles. We are learning 
        how to justify content on
        a web page. 
    </p>
</body>

</html>

Output:

Example 2:


<!DOCTYPE html>
<html>

<head>
    <title>Justified content</title>
</head>

<body>
    <h3>The content is justified</h3>

    <p align="justify">
        Welcome to Geeks for Geeks. It is 
        a computer science portal for geeks.
        It contains well written, well 
        thought articles. We are learning 
        how to justify content on
        a web page. 
    </p>
</body>

</html>

Output:

In this way align attribute is used to justify the content on the web page.

Article Tags :