HTML <td> Tag

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 3 Examples
Tables

What You’ll Learn

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.

01

Data Cells

Table values in rows.

02

Inside tr

Cells live in rows.

03

colspan

Merge columns.

04

rowspan

Merge rows.

05

td vs th

Data vs headers.

06

Best Practices

Consistent structure.

What Is the <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.

Valid HTML5 — Data Cell Semantics

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.

📝 Syntax

Wrap cell content between opening and closing td tags inside a tr row:

syntax.html
<td>Your data here</td>

Row of Data Cells

data-row.html
<tr>
  <td>John Doe</td>
  <td>25</td>
  <td>Web Developer</td>
</tr>

Syntax Rules

  • td must be a child of tr — never place it directly inside table.
  • Keep the same number of effective cells per row (accounting for colspan and rowspan).
  • Use th for column or row headers, not td, unless the cell is genuinely data.
  • Style cells with CSS rather than obsolete HTML presentational attributes.

⚡ Quick Reference

TopicCode SnippetNotes
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 thtd = datath = header
Browser supportUniversalAll browsers

⚖️ <td> vs <th>

ElementPurposeTypical placement
<td>Data cell (table data)tbody rows
<th>Header cell (column/row label)thead or row headers
Default styleNormal weight textBold, centered in many browsers
AccessibilityAnnounced as table cellAnnounced as column/row header

🧰 Attributes

The <td> tag supports colspan and rowspan plus global HTML attributes.

attributes.html
<td colspan="2">Spanning Two Columns</td>
<td rowspan="3">Spanning Three Rows</td>
colspan Spanning

Number of columns the cell should span horizontally.

colspan="2"
rowspan Spanning

Number of rows the cell should span vertically.

rowspan="3"
class / id Global

Hook for CSS to style individual cells or cell types.

class="highlight"
align / width / height Obsolete

Deprecated presentational attributes. Use CSS on td instead.

text-align: center

Examples Gallery

Basic data cells, column spanning, and row spanning with copy-ready code and live previews.

👀 Live Preview

Data cells in a table row:

NameAgeRole
John Doe25Web Developer

📚 Common Use Cases

Use <td> for standard table values, merged cells with colspan/rowspan, and CSS-styled data presentation.

Basic Data Cell

The primary use of td is defining data cells within a table row:

basic-data-cell.html
<tr>
  <td>John Doe</td>
  <td>25</td>
  <td>Web Developer</td>
</tr>
Try It Yourself

Spanning Columns

Use the colspan attribute to merge a cell horizontally across multiple columns:

spanning-columns.html
<tr>
  <td colspan="2">Spanning Two Columns</td>
  <td>Cell 3</td>
</tr>
Try It Yourself

Spanning Rows

Use the rowspan attribute to merge a cell vertically across multiple rows:

spanning-rows.html
<tr>
  <td rowspan="3">Spanning Three Rows</td>
  <td>Row 1, Col 2</td>
</tr>
<tr>
  <td>Row 2, Col 2</td>
</tr>
Try It Yourself

♿ Accessibility

  • Use th for headers — Column labels belong in th, not td.
  • Associate headers — In complex tables, use scope on th or headers on td.
  • Keep merged cells meaningful — Only use colspan/rowspan when the layout aids comprehension.
  • Add a caption — Describe the table purpose so data cells have context.

🧠 How <td> Works

1

Author adds data to cells

Values go inside td elements within each tr row.

Markup
2

Browser builds the grid

colspan and rowspan adjust how cells occupy the table grid.

Layout
3

CSS styles each cell

Borders, padding, and alignment are applied with CSS on td.

Design
=

Readable table data

Structured cells present information clearly in rows and columns.

Browser Support

The <td> tag is supported in all major browsers, including Internet Explorer.

Baseline · HTML4 / HTML5

Data cells everywhere

All browsers render <td> as standard table data cells.

100% Core tag support
Google Chrome Fully supported
Full support
Mozilla Firefox Fully supported
Full support
Apple Safari Fully supported
Full support
Microsoft Edge Fully supported
Full support
Internet Explorer Fully supported · EOL
Full support
Opera Fully supported
Full support
<td> tag 100% supported

Bottom line: Use <td> confidently for table data cells in any browser.

Conclusion

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.

💡 Best Practices

✅ Do

  • Keep a consistent number of cells per row
  • Use colspan and rowspan only when needed
  • Style cells with CSS for borders and padding
  • Place data values in td, headers in th

❌ Don’t

  • Use td for column header labels
  • Place td directly inside table
  • Rely on obsolete align, width, or height attributes
  • Use tables and td for page layout

Key Takeaways

Knowledge Unlocked

Six truths every developer should know about <td>

Bookmark these before you build your next table row.

6
Core concepts
📋 02

Inside tr

Row child.

Structure
03

colspan

Merge columns.

Attribute
04

rowspan

Merge rows.

Attribute
05

vs th

Data vs header.

A11y
🌐 06

100% Support

All browsers.

Compatibility

❓ Frequently Asked Questions

It defines a standard data cell inside a table row, holding the values displayed in the table.
td is for data values. th is for header labels that describe columns or rows.
colspan merges cells across columns. rowspan merges cells across rows.
Inside a tr element, within table, tbody, thead, or tfoot.
Yes. Full support in every major browser including Internet Explorer.

Fill your table with data

Practice <td> cells, colspan, and rowspan in the Try It editor.

Try basic data cells →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful