Home HTML Tags <td> HTML <td> Tag Definition
Definition and Usage The <td> element defines a table data cell . It must be a child of <tr> inside a <table> . Use it for values in the grid. For column or row labels, use <th> instead.
Span cells with colspan and rowspan . In complex tables, link a cell to its headers with headers . Prefer simple tables when you can.
Baseline · Widely available. Not deprecated. Core td support has been stable across browsers since about July 2015 (and much earlier in practice).
Deprecated attributes. Do not use abbr, align, axis, bgcolor, char, charoff, height, scope, valign, or width on <td>. Prefer CSS, and use scope only on <th>.
Syntax
HTML Syntax The start tag is required. The end tag may be omitted in some cases, but writing both tags is clearer. Content can be flow content (text, paragraphs, lists, and more).
Reference
Attributes The attributes you will use most often on <td>:
Attribute Description Try it colspanHow many columns the cell spans (default 1; max effectively 1000) Try itrowspanHow many rows the cell spans (default 1; 0 means through the end of the row group) Try itheadersSpace-separated id list of related <th> cells Try itbgcolorDeprecated — use CSS background-color instead Try it
Also deprecated (do not use on new pages): align , valign , width , height , axis , and scope (valid on th only).
Try it
Live Preview Change a data cell’s text and colspan on a real table.
Code
HTML Examples Short, copy-ready snippets. Use Try It Yourself for a live editor.
1. Basic cells 2. colspan 3. rowspan 4. headers Example 1 — Basic Data Cells Put values in <td> and labels in <th>.
<table>
<tr>
<th scope="col">Player</th>
<th scope="col">Score</th>
</tr>
<tr>
<th scope="row">Ada</th>
<td>92</td>
</tr>
<tr>
<th scope="row">Grace</th>
<td>88</td>
</tr>
</table> How It Works Each row is a <tr>. Cells sit inside that row.Use <th> for Player / Score labels and row names.Use <td> for the numeric scores.Keep columns aligned so every row has the same cell count (unless you span).Example 2 — colspan Let one data cell cover two columns.
<table>
<caption>Store hours</caption>
<tr>
<th scope="col">Day</th>
<th scope="col">Open</th>
<th scope="col">Close</th>
</tr>
<tr>
<td>Mon–Fri</td>
<td>9:00</td>
<td>18:00</td>
</tr>
<tr>
<td>Weekend</td>
<td colspan="2">Closed</td>
</tr>
</table> Store hours Day Open Close Mon–Fri 9:00 18:00 Weekend Closed
How It Works Count columns from the header (Day, Open, Close = 3).Set colspan="2" so one cell covers Open and Close.Check the math: Day (1) + spanned cell (2) = 3.Do not overlap cells with conflicting spans.Example 3 — rowspan Let one data cell stretch down across two rows.
<table>
<caption>Team shifts</caption>
<tr>
<th scope="col">Name</th>
<th scope="col">Shift</th>
<th scope="col">Desk</th>
</tr>
<tr>
<td>Ada</td>
<td>Morning</td>
<td rowspan="2">A1</td>
</tr>
<tr>
<td>Grace</td>
<td>Afternoon</td>
</tr>
</table> Team shifts Name Shift Desk Ada Morning A1 Grace Afternoon
How It Works Put rowspan="2" on the Desk cell in the first data row.Omit that column in the next row — the span fills it.rowspan="0" (advanced) extends to the end of the current row group.Keep spans simple ; heavy grids are harder for screen readers. Edge Cases & Pitfalls Most td mistakes are wrong cell type, broken spans, or presentational attributes.
semantics Do not fake headers with bold td Labels belong in <th>. Styling a td as bold does not make it a header for assistive tech.
spans Never overlap cells colspan / rowspan must leave a valid grid. Overlaps are invalid and render unpredictably.
scope scope is not for tdOn data cells, scope is deprecated. Use it on <th>, or use headers for complex links.
attrs Skip width / align / bgcolor Style cells with CSS. Presentational HTML attributes on td are obsolete.
parent Only inside tr <td> is invalid outside a table row. Always nest it under <tr>.
Compatibility
Browser Support The <td> element is core HTML table markup in every browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
<td> Widely available since about July 2015 (and long before). colspan, rowspan, and headers are broadly supported; presentational attributes are obsolete.
98% Global support (approx.)
Google Chrome All
Full support
Mozilla Firefox All
Full support
Apple Safari All
Full support
Microsoft Edge All
Full support
Opera All
Full support
Samsung Internet All
Full support
Internet Explorer All
Supported <td> Widely supported
Bottom line: Safe to use everywhere for data cells. Prefer th for headers, keep spans simple, and style with CSS.
Remember
Key Takeaways Role: <td> holds data values inside a <tr>.
vs th: labels → th; values → td.
Spans: colspan / rowspan merge cells without overlapping.
Complex a11y: use headers + id when needed.
One line: put each data value in a <td>, keep headers in <th>, and span cells only when the math stays valid.
UA style
Default CSS Settings Typical user-agent styling for td (simplified; exact rules vary by browser):
td {
display: table-cell;
vertical-align: inherit;
unicode-bidi: isolate;
padding: 1px;
} Learners often add borders and padding on th, td, and set border-collapse: collapse on the table.
Frequently Asked Questions What is the HTML td tag used for? The td element is a table data cell. Put it inside a tr to hold a value that belongs in the grid — not a column or row label (use th for those).
What is the difference between td and th? td is a normal data cell. th is a header cell for a column or row. Screen readers treat th as a heading for related cells.
How do colspan and rowspan work? colspan makes a cell cover extra columns; rowspan covers extra rows. Default for both is 1. Do not overlap cells with these attributes.
When should I use the headers attribute? In complex tables where scope alone is not enough, give each th an id and list those ids in headers on the related td cells.
Can td exist outside a table row? No. td is only valid as a child of tr (inside a table).
Should I use width, align, or bgcolor on td? No. Those attributes are deprecated. Style cells with CSS such as width, text-align, and background-color.
About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
12 people found this page helpful
Helpful Share Copy link Suggestion