HTML <td> tag

Updated: 09/12/2023 by Computer Hope
HTML td tag

When writing in HTML (hypertext markup language), the <td> tag designates a cell (table data) within a table containing data. The information contained in this element is left-aligned by default. The following sections contain information about the <td> tag, including an example of it in use, and related attributes and browser compatibility.

Tip

More advanced tables may include the <caption>, <col>, <colgroup>, <tbody>, <tfoot>, or <thead> elements.

Example of <td> code

<table class="mtable2 tab">
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr class="tcw">
<td>March</td>
<td>$200</td>
</tr>
<tr class="tcw">
<td>April</td>
<td>$300</td>
</tr>
<tr class="tcw"> <td>May</td>
<td>$250</td>
</tr>
</table>

Example result

Month Savings
March $200
April $300
May $250

We have added a few of our own classes to the table using CSS (cascading style sheets); this action allows us to improve its appearance.

Attributes

All HTML tags support standard attributes that define the settings of an HTML element. In addition to the standard settings, the <td> tag has the following unique attributes.

Attribute Description
abbr Designates an abbreviated version of the content within a cell.
colspan Designates how man columns a cell should span.
headers Designates one or more cells that a certain cell has relation.
rowspan Designates how man rows a cell should span.
scope Designates a way to associate header cells and data cells in the same table.
sorted Designates the sorting direction of a column.

Deprecated attributes

In addition to the above attributes, the <td> tag had the following deprecated attributes.

Attribute Description
align Designates the alignment of content inside an element.
axis Used to categorize cells.
bgcolor Designates the background color of a cell.
char Aligns the content in a cell to a specific character.
charoff Sets the number of characters to offset the content from the character designated by the char attribute.
height Designates the height of a cell.
nowrap Designates that the content inside a cell should not wrap.
valign Alights the content in a cell vertically.
width Designates the width of a cell.

Compatibility

Edge Internet Explorer Firefox Safari Opera Chrome
All versions All versions All versions All version All versions All versions

Browser, Cell, Class, Column, Compatibility, Computer abbreviations, Container tag, Format, Row, <table>, <th>, <tr>, Web design terms