The Wayback Machine - https://web.archive.org/web/20240610152920/https://www.geeksforgeeks.org/html-align-attribute/
Open In App

HTML align Attribute

Last Updated : 28 Dec, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

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: “. For horizontal alignment, use align with values like “left,” “center,” or “right” within appropriate tags.

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

Supported Tags: 

Syntax:

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

Attribute Values:

Attribute Values

Description

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 align attribute with an example.

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 align attribute with another example.

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 1
  • Edge 12
  • Firefox 1
  • Apple Safari 3
  • Opera 12.1


Previous Article
Next Article

Similar Reads

Difference between align-content and align-items
Both align-content and align-items function on the cross-axis.Cross-axis in flexbox is dependent on the flex-direction and runs perpendicular to the main-axis, if flex-direction is either row or row-reverse then the cross-axis is vertical, if flex-direction is either column or column-reverse then the cross-axis is horizontal. align-content align-it
4 min read
HTML | &lt;col&gt; align Attribute
The HTML &lt;col&gt; align Attribute is used to set the horizontal alignment of text content inside the col element. It is not supported by HTML 5. Syntax: &lt;col align="left | right | center | justify | char"&gt; Attribute Values: left: It sets the text left-align. right: It sets the text right-align. center: It sets the text center-align. justif
1 min read
HTML | &lt;tbody&gt; align Attribute
The HTML &lt;tbody&gt; align Attribute is used to set the horizontal alignment of text content inside the table body (tbody). Syntax: &lt;tbody align="left | right | center | justify | char"&gt; Attribute Value: left: It sets the text left-align. right: It sets the text right-align. center: It sets the text center-align. By default, it is set to ce
1 min read
HTML | &lt;tfoot&gt; align Attribute
The HTML &lt;tfoot&gt; align Attribute is used to set the horizontal alignment of text content inside the table footer (tfoot). It is not supported by HTML 5. Syntax: &lt;tfoot align="left | right | center | justify | char"&gt; Attribute Value: left: It sets the table footer text left-align. right: It sets the table footer text right-align. center:
1 min read
HTML | &lt;legend&gt; align Attribute
The &lt;legend&gt; align attribute in HTML is used to specify the alignment of the caption in a &lt;fieldset&gt; element. The left and right alignment of &lt;legend&gt; element are supported by major browsers except Opera 12 and earlier versions. The bottom alignment are not supported by any browsers.Syntax: &lt;legend align="left|right|top|bottom"
2 min read
HTML | &lt;caption&gt; align Attribute
The HTML &lt;caption&gt; align Attribute is used to specify the alignment of the &lt;caption&gt; Element. It is used to align the caption to the left, right, top and Bottom of a table. This attribute is not supported in HTML5. Note: By default , the table caption is aligned to center. Syntax: &lt;caption align="left | right | top | bottom&gt; Attri
2 min read
HTML | &lt;colgroup&gt; align Attribute
The HTML &lt;colgroup&gt; align attribute is used to set the horizontal alignment of the text or content in the group of column. Syntax: &lt;colgroup align="left|right|center|justify|char&gt; Attribute Values: left: It sets the content to the left-align.right: It sets the content to the right-align.center: It sets the content to the center.justify:
1 min read
HTML | &lt;thead&gt; align Attribute
The HTML &lt;thead&gt; align attribute is used to set the horizontal alignment of text content inside the table head (thead) section. Syntax: &lt;thead align="left|right|center|justify|char"&gt; Note: This attribute has been DEPRECATED and is no longer recommended. Attribute Value: left: It sets the text left-align.right: It sets the text right-ali
1 min read
HTML | applet align Attribute
The HTML applet align attribute is used to specify the alignment of the &lt;applet&gt; element or the content present inside the applet element. Note: This attribute is not supported by HTML5. Syntax: &lt;applet align="left | right | center | justify";&gt; Attribute Values: left: It sets the content to the left-align. right: It sets the content to
1 min read
HTML &lt;p&gt; align Attribute
The HTML &lt;p&gt; align Attribute is used to specify the alignment of paragraph text content. The align attribute in &lt;p&gt; 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:&lt;p align="left
2 min read