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

HTML <td> align Attribute

Last Updated : 22 Dec, 2023
Improve
Suggest changes
Post a comment
Like Article
Like
Save
Share
Report

The HTML <td> align attribute is used to set the horizontal alignment of text content. It uses the align attribute in HTML <td> to horizontally align text content within a table cell and it sets “left,” “center,” or “right” to control horizontal alignment.

Note: The <td> align attribute is not supported by HTML5 instead uses CSS.

Syntax:

<td align ="left | right | center | justify | char ">

Attribute Values:

The <td> align attributes have the following attributes which are as:

Attributes

Description

left

It sets the text left-aligned of a container.

right

It sets the text right-align of the container.

center

It sets the text center-align.

justify

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

char

It sets the text-align to a specific character.

Example:

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

html




<!DOCTYPE html>
<html>
  
<head>
    <title>
        HTML td align Attribute
    </title>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
  
    <h2>HTML td align Attribute</h2>
  
    <table width="500" border="1">
        <tr>
            <th>NAME</th>
            <th>AGE</th>
            <th>BRANCH</th>
        </tr>
  
        <tr>
            <td align="center">BITTU</td>
            <td align="left">22</td>
            <td align="right">CSE</td>
        </tr>
  
        <tr>
            <td align="center">RAKESH</td>
            <td align="left">25</td>
            <td align="right">EC</td>
        </tr>
    </table>
</body>
  
</html>


Output:

tdalign

Example:

In this example, we will see the implementation of the <td> align tag with another example.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title>
        HTML td align Attribute
    </title>
    <style>
        h1,
        h2 {
            text-align: center;
            color: green;
        }
    </style>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
  
    <h2>HTML td align Attribute</h2>
  
    <table width="500" border="1">
        <tr>
            <th>NAME</th>
            <th>AGE</th>
            <th>BRANCH</th>
        </tr>
  
        <tr>
            <td style="text-align: center;">BITTU</td>
            <td style="text-align: left;">22</td>
            <td style="text-align: right;">CSE</td>
        </tr>
  
        <tr>
            <td style="text-align: left;">RAKESH</td>
            <td style="text-align: center;">25</td>
            <td style="text-align: left;">EC</td>
        </tr>
    </table>
</body>
  
</html>


Output:

Screenshot-2023-12-05-152510

Output

Supported Browsers:

  • Google Chrome 1 and above
  • Microsoft Edge 12 and above
  • Firefox 1 and above
  • Opera 12.1 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.



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;table&gt; align Attribute
The HTML &lt;table&gt; align Attribute is used to specify the alignment of the table and its content. Instead of the align attribute, CSS properties like margin and text-align are preferred for table alignment. For aligning content within table rows or cells, use the align attribute within &lt;tr&gt; and or apply CSS styles. Note: This attribute is
2 min read
three90RightbarBannerImg