English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
HTML <td> tag defines a standard cell in an HTML table. The <td> element defines a table cell containing data. This tag is also commonly referred to as the <td> element.
HTML tables with multiple cells:
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>HTML td tag usage (Basic Tutorial Website oldtoolbag.com)</title> </head> <body> <table border="1"> <tr> <th>Column 1 Heading</th> <th>Column 2 Heading</th> </tr> <tr> <td>Data in Column 1, Row 2</td> <td>Data in Column 2, Row 2</td> </tr> <tr> <td>Data in Column 1, Row 3</td> <td>Data in Column 2, Row 3</td> </tr> <tr> <td>Data in Column 1, Row 4</td> <td>Data in Column 2, Row 4</td> </tr> </table> </body> </html>Test see ‹/›
In this HTML5in the document example, we used the <table> tag to create a table that has2columns and4rows.1row is defined by the first2cells are defined by the <th> tag. The2to4Rows are defined by the <td> tag to define standard table cells.
IEFirefoxOperaChromeSafari
All major browsers support the <td> tag.
The <td> tag defines the standard cell in an HTML table.
HTML tables have two types of cells:
header cell - Contains header information (created by <th> element created)
standard cell - Contains data (created by
The text in the <th> element is usually bold and centered.
The text in the <td> element is usually left-aligned plain text.
Hint:If you need to span content across multiple rows or columns, use the colspan and rowspan attributes!
HTML 5 No longer supports HTML 4.01 Some attributes in
Attribute | Value | Description |
---|---|---|
abbr | text | HTML5 Not supported. Specify the abbreviated version of the content in the cell. |
align | left right center justify char | HTML5 Not supported. Specify the horizontal alignment of the cell content. |
axis | category_name | HTML5 Not supported. Classify the cell. |
bgcolor | rgb(x,x,x) #xxxxxx colorname | HTML5 Not supported. HTML 4.01 Deprecated. Specify the background color of the cell. |
char | character | HTML5 Not supported. Specify the character to align the content based on. |
charoff | number | HTML5 Not supported. Specify the offset of the alignment character. |
colspan | number | Specify the number of columns that a cell can span horizontally. |
headers | header_id | Specify one or more header cells associated with the cell. |
height | pixels % | HTML5 Not supported. HTML 4.01 Deprecated. Set the height of the cell. |
nowrap | nowrap | HTML5 Not supported. HTML 4.01 Deprecated. Specify whether the content in a cell wraps. |
rowspan | number | Set the number of rows that a cell can span horizontally. |
scope | col colgroup row rowgroup | HTML5 Not supported. Defines the method to associate header cells with data cells. |
valign | top middle bottom baseline | HTML5 Not supported. Specifies the vertical alignment of the cell content. |
width | pixels % | HTML5 Not supported. HTML 4.01 Deprecated. Specifies the width of the cell. |
Support for <td> tag Global Attributes of HTML.
Support for <td> tag HTML Event Attributes.
Table cells that span rows or columns
This example demonstrates how to define table cells that span rows or columns.
Tags within Tables
This example demonstrates how to display elements within different elements.
Cell padding
This example demonstrates how to use Cell padding to create space between the cell content and its border.
Cell spacing
This example demonstrates how to use Cell spacing to increase the distance between cells.
HTML Tutorial:HTML Tables
HTML DOM Reference Manual: Td Object