HTML <td>Tag


Examples

A simple HTML table with two cells:

<table border="1">
<tr>
<td>Cell A</td>
<td>Cell B</td>
</tr>
</table>

Try it Yourself »
(More examples at the bottom of the page)

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the <td> tag.


Tag Definition and Usage Instructions

The <td> tag defines a standard cell in an HTML table.

An HTML table has two kinds of cells:

  • Header cells - contain header information (created by the<th>element)
  • Standard cells - contain data (created by the <td> element)

Text in <th> elements is usually displayed in bold and centered.

Text in <td> elements is usually regular left-aligned text.


Tips and Notes

Tip:If you need to span content across multiple rows or columns, use the colspan and rowspan attributes!


Differences between HTML 4.01 and HTML5

Some attributes in HTML 4.01 are no longer supported in HTML5.


Attributes

Attribute Value Description
abbr text Not supported in HTML5.Specifies an abbreviated version of the content in the cell.
align left
right
center
justify
char
Not supported in HTML5.Specifies the horizontal alignment of the cell content.
axis category_name Not supported in HTML5.Classifies the cell.
bgcolor rgb(x,x,x)
#xxxxxx
colorname
Not supported in HTML5. Deprecated in HTML 4.01.Specifies the background color of the cell.
char character Not supported in HTML5.Specifies which character to align the content with.
charoff number Not supported in HTML5.Specifies the offset of the alignment character.
colspan number Specifies the number of columns a cell can span.
headers header_id Specifies one or more header cells associated with the cell.
height pixels
%
Not supported in HTML5. Deprecated in HTML 4.01.
Sets the height of the cell.
nowrap nowrap Not supported in HTML5. Deprecated in HTML 4.01.
Specifies whether the content in the cell should wrap.
rowspan number Sets the number of rows a cell can span vertically.
scope col
colgroup
row
rowgroup
Not supported in HTML5.Defines a method for associating header cells with data cells.
valign top
middle
bottom
baseline
Not supported in HTML5.Specifies the vertical alignment of the cell content.
width pixels
%
Not supported in HTML5. Deprecated in HTML 4.01.Specifies the width of the cell.


Global Attributes

The <td> tag supportsthe HTML Global Attributes。


Event Attributes

The <td> tag supportsthe HTML Event Attributes。


Examples

Try it Yourself - Examples

Table headings
This example demonstrates how to display table headings.

Empty cells
This example demonstrates how to use "&nbsp;" to handle cells with no content.

Table with a caption
This example demonstrates a table with a caption.

Tags inside a table
This example demonstrates how to display elements within other elements.

Table cells spanning rows or columns
This example demonstrates how to define table cells that span rows or columns.


Related Articles

HTML Tutorial:HTML Tables

HTML DOM Reference:Td Object

Other extensions