👀 Live Preview
Data cells in a table row:
| Name | Age | Role |
|---|---|---|
| John Doe | 25 | Web Developer |

The <td> tag defines a data cell in an HTML table. This guide covers syntax, colspan and rowspan, td vs th, CSS styling, accessibility, and best practices for beginners.
Table values in rows.
Cells live in rows.
Merge columns.
Merge rows.
Data vs headers.
Consistent structure.
<td> Tag?The <td> tag is an HTML element that represents a table data cell. The name stands for “table data.” Each td holds one piece of information inside a table row.
Use td for standard data values in tbody rows. Use th for header labels in thead or row-header cells.
A td element must be placed inside a tr (table row), which in turn sits inside table, tbody, thead, or tfoot.
Wrap cell content between opening and closing td tags inside a tr row:
<td>Your data here</td><tr>
<td>John Doe</td>
<td>25</td>
<td>Web Developer</td>
</tr>td must be a child of tr — never place it directly inside table.colspan and rowspan).th for column or row headers, not td, unless the cell is genuinely data.| Topic | Code Snippet | Notes |
|---|---|---|
| Basic td | <td>...</td> | Data cell |
| Parent | <tr><td>...</td></tr> | Inside row |
| colspan | <td colspan="2"> | Merge columns |
| rowspan | <td rowspan="3"> | Merge rows |
| vs th | td = data | th = header |
| Browser support | Universal | All browsers |
<td> vs <th>| Element | Purpose | Typical placement |
|---|---|---|
<td> | Data cell (table data) | tbody rows |
<th> | Header cell (column/row label) | thead or row headers |
| Default style | Normal weight text | Bold, centered in many browsers |
| Accessibility | Announced as table cell | Announced as column/row header |
The <td> tag supports colspan and rowspan plus global HTML attributes.
<td colspan="2">Spanning Two Columns</td>
<td rowspan="3">Spanning Three Rows</td>colspan SpanningNumber of columns the cell should span horizontally.
colspan="2"rowspan SpanningNumber of rows the cell should span vertically.
rowspan="3"class / id GlobalHook for CSS to style individual cells or cell types.
class="highlight"align / width / height ObsoleteDeprecated presentational attributes. Use CSS on td instead.
text-align: centerBasic data cells, column spanning, and row spanning with copy-ready code and live previews.
Data cells in a table row:
| Name | Age | Role |
|---|---|---|
| John Doe | 25 | Web Developer |
Use <td> for standard table values, merged cells with colspan/rowspan, and CSS-styled data presentation.
The primary use of td is defining data cells within a table row:
<tr>
<td>John Doe</td>
<td>25</td>
<td>Web Developer</td>
</tr>Use the colspan attribute to merge a cell horizontally across multiple columns:
<tr>
<td colspan="2">Spanning Two Columns</td>
<td>Cell 3</td>
</tr>Use the rowspan attribute to merge a cell vertically across multiple rows:
<tr>
<td rowspan="3">Spanning Three Rows</td>
<td>Row 1, Col 2</td>
</tr>
<tr>
<td>Row 2, Col 2</td>
</tr>th, not td.scope on th or headers on td.colspan/rowspan when the layout aids comprehension.Values go inside td elements within each tr row.
colspan and rowspan adjust how cells occupy the table grid.
Borders, padding, and alignment are applied with CSS on td.
Structured cells present information clearly in rows and columns.
The <td> tag is supported in all major browsers, including Internet Explorer.
All browsers render <td> as standard table data cells.
Bottom line: Use <td> confidently for table data cells in any browser.
Mastering the <td> tag is essential for building HTML data tables. Whether filling simple rows or merging cells with colspan and rowspan, td lets you organize and present tabular information effectively.
colspan and rowspan only when neededtd, headers in thtd for column header labelstd directly inside tablealign, width, or height attributestd for page layout<td>Bookmark these before you build your next table row.
Table values.
PurposeRow child.
StructureMerge columns.
AttributeMerge rows.
AttributeData vs header.
A11yAll browsers.
Compatibilitytd is for data values. th is for header labels that describe columns or rows.colspan merges cells across columns. rowspan merges cells across rows.tr element, within table, tbody, thead, or tfoot.Practice <td> cells, colspan, and rowspan in the Try It editor.
6 people found this page helpful