asp.net.ph

Skip Navigation LinksHome > Abakada: Back to Basics > Language References > HTML Elements > TD Element

<td> Element


Denotes a table data cell.HTML 3.2, 4, 4.01, 5

HTML Syntax

A <td> element’s end tag can be omitted if the <td> element is immediately followed by a <td> or <th> element, or if there is no more content in the parent element.

Remarks

The <td> element specifies a table cell which contain the table data.

<td> elements can only be used inside table rows, or within a <tr> element.

Each <td> cell normally occupies only one column in one row, though authors can specify how many columns and rows the cell spans by use of the colspan and rowspan attributes.

cellspacing, or the distance between cells, and cellpadding, or the distance between the boundaries of each cell and its contents, are set at the <table> element level. As such, all cells in a table have the same padding and spacing.

A cell can be empty, that is, the <td> element has no content. However, authors must still provide the <td> element for any cell that is empty, so as not to collapse the table structure.

An empty cell can be made to behave like other cells in the table, having the same background color, border or other style attribute, by having a non-breaking space for its content, as in <td>&nbsp;</td>. If not, the space occupied by the cell will be completely empty: no content, no background color, and no border.

Although the W3C specifies that <td> end tags are optional and may be omitted, it is safer to always close table data cells, as not all browsers support this recommendation, and may produce unexpected results.

Attributes

The <td> element supports the following attributes, in addition to global attributes common to all HTML elements.

AttributeValueDescription
colspannumberSpecifies the number of columns a cell should span
headersheader_idSpecifies one or more header cells a cell is related to
rowspannumberSets the number of rows a cell should span

Example

The following example shows how the <td> element may be used.

<table table align="center" border>
<thead>
<tr>
   <th>Heading 1</th>
   <th>Heading 2</th>
</tr>
<tbody>
<tr>
   <td>Row 1, Column 1 text.</td>
   <td>Row 1, Column 2 text.</td>
</tr>
<tr>
   <td>Row 2, Column 1 text.</td>
   <td>Row 2, Column 2 text.</td>
</tr>
</table>

which would render on a Web page as follows:

Heading 1Heading 2
Row 1, Column 1 text.Row 1, Column 2 text.
Row 2, Column 1 text.Row 2, Column 2 text.

External References

See Also

TABLE   TBODY   TFOOT   THEAD   TH   TR   Using Tables


Need a break ?
Suggested Reading

Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph.

If you have any question, comment or suggestion,
please send us a note