Open In App
Related Articles

HTML align Attribute

Improve Article
Improve
Save Article
Save
Like Article
Like

HTML align Attribute in HTML is used to specify the alignment of the text content of The Element. this attribute is used in all elements. The Align attribute can also be set using the CSS property “text-align: ” or in <img> “vertical-align: “.

Supported Tags: 

Syntax:

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

Attribute Values:

  • left: It sets the text left-align.
  • right: It sets the text right-align.
  • center: It sets the text center-align.
  • justify: It stretches the text of a paragraph to set the width of all lines equal.

Example 1: This example shows the use of the above approach.

html




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML p align Attribute
    </title>
</head>
 
<body>
    <h1>GeeksforGeeks</h1>
 
    <h2>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:

Example 2: This example shows the use of the above approach.

html




<!DOCTYPE html>
<html>
 
<head>
    <title>gfg</title>
</head>
 
<body>
    <h1>GeeksForGeeks</h1>
    <h2>
        div align Attribute
    </h2>
    <div align="center">
        div align="center"
    </div>
    <div align="left">
        div align="left"
    </div>
    <div align="right">
        div align="right"
    </div>
    <div align="justify">
        div align="justify"
    </div>
</body>
 
</html>


Output: 

Screenshot-from-2023-07-03-16-22-28.png

HTML align attribute

Supported Browsers: 

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Apple Safari
  • Opera

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 24 Nov, 2023
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials