HTML Tag Reference - HTML tag <td>








This <td> element creates a cell in a table. This element is used in conjunction with the <table> and <tr> elements. For each table row(<tr>) you can have one or more table details(<td>,cells).

Browser compatibility

<td> Yes Yes Yes Yes Yes

What's new in HTML5

All layout attributes are deprecated in HTML5.

Attribute

Attribute Value Description
abbr text Not supported in HTML5.
Set an abbreviated for the cell content
align left
right
center
justify
char
Not supported in HTML5.
Align the cell content
axis category_name Not supported in HTML5.
Categorizes cells
bgcolor rgb(x,x,x)
#xxxxxx
colorname
Not supported in HTML5.
Set the cell background color
char character Not supported in HTML5.
Align the cell content to a character
charoff number Not supported in HTML5.
Sets the number of characters to align the content from the character in the char attribute
colspan number Set the number of columns a cell should span
headers header_id Set one or more header cells for the cell
height pixels
%
Not supported in HTML5.
Sets the cell height
nowrap nowrap Not supported in HTML5.
Set that the cell content should not wrap
rowspan number Sets the number of rows a cell should span
scope col
colgroup
row
rowgroup
Not supported in HTML5.
Associate header cells and data cells in a table
valign top
middle
bottom
baseline
Not supported in HTML5.
Vertical aligns the cell content
width pixels
%
Not supported in HTML5.
Set the cell width




Global Attributes

The <td> tag supports the Global Attributes in HTML.

Event Attributes

The <td> tag supports the Event Attributes in HTML.

Default CSS Settings

td {
    display: table-cell;
    vertical-align: inherit;
}

Example

A demo showing how to use <td> tag.

<html>
<body>
     <table>
          <tr>
               <td>Cell 1</td>
               <td>Cell 2</td>
          </tr>
          <tr>
               <td>Cell 3</td>
               <td>Cell 4</td>
          </tr>
     </table>
</body><!--   w w  w  . j  a v a2  s . c  o m-->
</html>

Click to view the demo





colspan attribute

This attribute determines how many columns in a table a particular cell spans.

<html>
<body>
     <table border="1">
          <tr>
               <th colspan="3">First Header (3 cells spanned)</th>
               <th>Second Header</th>
          </tr>
          <tr>
               <td height="79">Cell 1 content</td>
               <td height="79">Cell 2 content</td>
               <td height="79">Cell 3 content</td>
               <td height="79">Cell 4 content</td>
          </tr>
     </table>
</body><!--   w  w w .j a v  a2  s .c  o m-->
</html>

Click to view the demo