HTML <td> Tag

The <td> tag adds a table cell to an HTML table.

A table cell is a boxed area that displays a single data item.



Six <td> tags with data in a table.

First name Last name
Denice Hobermann
Paulo Cornell
Jane Hollander
  table.tb { width:300px; border-collapse: collapse; }
  .tb th, .tb td { border: solid 1px #777; padding: 5px; }
  .tb th {background-color: lightblue; }

<table class="tb">
    <th>First name</th>
    <th>Last name</th>
td = table data cell

Using <td>

The <td> tag creates a standard table cell.

The purpose of the <td> element is to display a single data item.

By default, this element is rendered in normal font and is left aligned.

More Examples

A table with 35 <td> elements, each one with data.

First name Last name Email City Country
Tim Hallman Dallas USA
Jelle van Loenen Arnhem Netherlands
Jose Lopez Manila Philippines
Jeroen Harmsma The Hague Netherlands
Sunil Gupta Mumbai India
Henry Wong San Francisco USA
Cindy Velasquez Mexico City Mexico
 table.tbl { width:100%; border-collapse: collapse; }
 .tbl th, .tbl td { padding:3px; border: 1px solid #999; }
 .tbl th { background-color:lightblue; }

<table class="tbl">
    <th>First name</th>
    <th>Last name</th>
    <td>van Loenen</td>
  </tr> <tr>
    <td>The Hague</td>
    <td>San Francisco</td>
    <td>Mexico City</td>

Attributes for <td>

This table lists the <td> tag attributes.

Attribute Value Description
rowspan number Number of rows the cell extends.
colspan number Number of columns the cell extends.
id   identifier Defines a unique identifier for the data cell.
class   classnames Sets one or more CSS classes to be applied to the data cell.
style   CSS-styles Sets the style for the data cell.
data-*   value Defines additional data that can be used by JavaScript.
title   text Sets a title that displays as a tooltip.
headers header-id Id of the header the current table cell is related to.

For additional global attributes see our global attributes list.

Obsolete Attributes

Do not use the attributes listed below.  They are no longer valid on thead in HTML5.

Attribute Description Alternative
abbr Contains abbreviated description of the cell's content. <abbr> tag
align Aligns the content in the td element. CSS text-align
axis List of headers ids that cell applies to. headers attribute
bgcolor Defines the background color for the td element. CSS text-align
char Aligns content to a character, for example "," or ".". CSS text-align
charoff Shifts column data to the right relative to char attribute. CSS text-align
height Sets the height of the td element. CSS height
scope Defines the header cells the td element is related to. Use scope on th only
valign Sets the vertical alignment of content in the td element. CSS vertical-align
width Sets the width of the td element. CSS width

Table Tags

The <td> tag is part of a group of tags that are used to create HTML tables. This group is referred to as the Table tag group. Together, they allow you to create comprehensive HTML tables.

Here is a list of table tags

Element Description
<table> Creates a table that contains elements listed below
<caption> Creates a caption above or under a table
<colgroup> Creates a container for col elements
<col> Creates a style for one or more columns in a table
<thead> Creates a table header that can style all header cells
<tbody> Creates a table body that can style all data cells
<tfoot> Creates table footer that can style all footer cells
<tr> Creates a table row that contains table cells
<th> Creates a table header cell
<td> Creates a table data cell

Browser support

Here is when <td> support started for each browser:

1.0 Sep 2008
1.0 Sep 2002
1.0 Aug 1995
1.0 Jan 2006
1.0 Jan 2003

You may also like

Last updated on Sep 30, 2023