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

HTML <table> align Attribute

Last Updated : 02 May, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The HTML <table> 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 <tr> and or apply CSS styles.

Note: This attribute is not supported by HTML5.

Syntax

<table align="left | right | center">

Attribute Values

Attributes

Descriptions

left

It sets the left align to the table. It is a default value.

right

It sets the right align to the table.

center

It sets the center align to the table.

Example 1: In this example, we will see the implementation of the align-right attribute with an example.

html




<!DOCTYPE html>
<html>
  
<head>
    <title>
        HTML table align Attribute
    </title>
</head>
  
<body>
    <h1 style="green">GeeksforGeeks</h1>
  
    <h2>HTML table align Attribute</h2>
  
    <table border="1" align="right">
        <caption>Author Details</caption>
  
        <tr>
            <th>NAME</th>
            <th>AGE</th>
            <th>BRANCH</th>
        </tr>
        <tr>
            <td>BITTU</td>
            <td>22</td>
            <td>CSE</td>
        </tr>
        <tr>
            <td>RAM</td>
            <td>21</td>
            <td>ECE</td>
        </tr>
    </table>
</body>
  
</html>


Output:

Example 2: In this example, we will see the implementation of the align-left attribute.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title>
        HTML table align Attribute
    </title>
</head>
  
<body>
    <h1 style="green">GeeksforGeeks</h1>
  
    <h2>HTML table align Attribute</h2>
  
    <table border="1" align="left">
        <caption>Author Details</caption>
  
        <tr>
            <th>NAME</th>
            <th>AGE</th>
            <th>BRANCH</th>
        </tr>
        <tr>
            <td>BITTU</td>
            <td>22</td>
            <td>CSE</td>
        </tr>
        <tr>
            <td>RAM</td>
            <td>21</td>
            <td>ECE</td>
        </tr>
    </table>
</body>
  
</html>


Output:

Screenshot-2023-12-04-150504

Example 3: In this example, we will see the implementation of the align-center attribute.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title>
        HTML table align Attribute
    </title>
</head>
<style>
    h1,
    h2 {
        text-align: center;
    }
</style>
  
<body>
    <h1 style="green">GeeksforGeeks</h1>
  
    <h2>HTML table align Attribute</h2>
  
    <table border="1" align="center">
        <caption>Author Details</caption>
  
        <tr>
            <th>NAME</th>
            <th>AGE</th>
            <th>BRANCH</th>
        </tr>
        <tr>
            <td>BITTU</td>
            <td>22</td>
            <td>CSE</td>
        </tr>
        <tr>
            <td>RAM</td>
            <td>21</td>
            <td>ECE</td>
        </tr>
    </table>
</body>
  
  
</html>


Output:

Screenshot-2023-12-04-151031

Supported Browsers

  • Google Chrome 1 and above
  • Microsoft Edge 12 and above
  • Firefox 1 and above
  • Opera 12.1 and above
  • Safari 3 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;td&gt; align Attribute
The HTML &lt;td&gt; align attribute is used to set the horizontal alignment of text content. It uses the align attribute in HTML &lt;td&gt; to horizontally align text content within a table cell and it sets "left," "center," or "right" to control horizontal alignment. Note: The &lt;td&gt; align attribute is not supported by HTML5 instead uses CSS.
2 min read
three90RightbarBannerImg