**`<td>`** ("table data") holds an individual value within a table row — as opposed to `<th>`, which holds a header labeling that value. Two important attributes let a cell span multiple positions: **`colspan`** merges it across multiple columns, and **`rowspan`** merges it down across multiple rows — useful for grouping related data or creating a cell that applies to several rows/columns at once.
1Understanding <td>
`<td>` ("table data") holds an individual value within a table row — as opposed to <th>, which holds a header labeling that value. Two important attributes let a cell span multiple positions: `colspan` merges it across multiple columns, and `rowspan` merges it down across multiple rows — useful for grouping related data or creating a cell that applies to several rows/columns at once.
When using colspan or rowspan, remember every OTHER row still needs the correct number of cells to keep the table's grid consistent — a merged cell effectively 'removes' that many cell slots from the rows/columns it spans.
<table>
<tr><th>Item</th><th>Qty</th></tr>
<tr><td>Pen</td><td>3</td></tr>
<tr><td>Notebook</td><td>1</td></tr>
</table>2Practical Example
Here is a real-world application of <td> showing how it is used in production HTML.
<!-- Merging a cell across two rows -->
<tr>
<td rowspan="2">Shared value</td>
<td>Row 1 detail</td>
</tr>
<tr>
<td>Row 2 detail</td>
</tr>3Best Practices
Follow these guidelines when working with <td>:
1. Use <td> for actual data values, and <th> for labels/headers — don't use <td> for headers
2. Use colspan/rowspan to merge related cells instead of duplicating content across cells
3. Keep cell content concise; move lengthy explanations outside the table when possible
Tip: When using colspan or rowspan, remember every OTHER row still needs the correct number of cells to keep the table's grid consistent — a merged cell effectively 'removes' that many cell slots from the rows/columns it spans.
<table>
<tr><th>Item</th><th>Qty</th></tr>
<tr><td>Pen</td><td>3</td></tr>
<tr><td>Notebook</td><td>1</td></tr>
</table>