👀 Live Preview
Table with thead headers and tbody data rows:
| Name | Age |
|---|---|
| John | 25 |
| Mary | 30 |

The <tbody> tag groups the main data rows of a table. This guide covers syntax, thead/tbody/tfoot structure, CSS styling, accessibility, and best practices for beginners.
Group data rows.
Headers vs data.
Striped and bold rows.
Inside table element.
thead, tbody, tfoot.
Semantic structure.
<tbody> Tag?The <tbody> tag is an HTML element used inside <table> to define the body section of a table. It groups the main data rows, separating them from header rows in thead and summary rows in tfoot.
tbody wraps one or more tr elements that contain the primary table data. Use it with thead for clear, semantic table structure.
If you omit tbody, browsers automatically wrap rows in an implicit tbody. Writing it explicitly makes your markup clearer and easier to style.
Place tbody inside table and add tr rows with td or th cells:
<table>
<tbody>
<!-- Your table rows (tr) with data cells (td/th) here -->
</tbody>
</table><table>
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>25</td>
</tr>
</tbody>
</table>tbody must be a direct child of table (along with caption, colgroup, thead, and tfoot).tr elements go directly inside tbody.thead before tbody and tfoot after tbody in source order.tbody elements for separate row groups.| Topic | Code Snippet | Notes |
|---|---|---|
| Basic tbody | <tbody>...</tbody> | Row group |
| With thead | thead + tbody | Header + data |
| Child rows | <tr><td>...</td></tr> | Data cells |
| CSS class | class="striped-table" | Body styling |
| vs thead | tbody = data | thead = headers |
| Browser support | Universal | All browsers |
<thead>, <tbody>, and <tfoot>| Element | Contains | Typical cells |
|---|---|---|
<thead> | Header rows | th column labels |
<tbody> | Main data rows | td data values |
<tfoot> | Footer / summary rows | Totals, averages |
| Order in HTML | thead → tbody → tfoot | Semantic grouping |
The <tbody> tag has no tag-specific attributes. Use global attributes for styling and scripting hooks.
<tbody class="striped-table">
<!-- Your table rows (tr) with data cells (td/th) here -->
</tbody>class / id GlobalTarget all body rows for striped backgrounds or emphasis.
class="striped-table"style GlobalInline styles on tbody affect the row group container.
style="background: #f8fafc"lang OptionalDeclare language when body cell text differs from the page.
lang="en"align / valign ObsoleteDeprecated presentational attributes. Use CSS on td and th instead.
text-align: leftStructured tabular data, striped body styling, and highlighted rows with copy-ready code and live previews.
Table with thead headers and tbody data rows:
| Name | Age |
|---|---|
| John | 25 |
| Mary | 30 |
Use <tbody> to structure tabular data, separate headers from body content, and apply body-level styling.
The primary purpose of tbody is organizing the main body of tabular data, separate from thead and tfoot:
<table>
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</tbody>
</table>Apply a class to tbody for striped or background styling on all body rows:
<tbody class="striped-table">
<tr>
<td>John</td>
<td>25</td>
</tr>
</tbody>Use a class on tbody to emphasize all data cells in the body section:
<tbody class="highlighted-rows">
<tr>
<td>Alice</td>
<td>25</td>
</tr>
</tbody>thead give context to tbody data cells.thead, not mixed into tbody unless using row headers.caption describes the whole table including its body data.tbody in layout tables; it confuses assistive technologies.Main tr rows with td cells go inside tbody.
thead headers and tbody data render as distinct row groups.
Classes on tbody target all body rows for stripes or emphasis.
Data rows are semantically grouped, styled, and easier to maintain.
The <tbody> tag is supported in all major browsers, including Internet Explorer.
All browsers render <tbody> as the standard table row group.
Bottom line: Use <tbody> confidently to group table data rows in any browser.
The <tbody> tag is essential for organizing tabular data. By grouping data rows separately from headers and footers, you improve clarity, styling control, and semantic structure in your HTML tables.
tbody with thead for structured tablestbody for striped or bold stylingthead, data rows in tbodytbody for clearer, maintainable markuptbody without reasonalign or valign on tbodytbody outside of table<tbody>Bookmark these before you structure your next HTML table.
Data rows.
PurposeHeader section.
PairingStriped rows.
StylingData vs footer.
ComparisonClear structure.
A11yAll browsers.
Compatibilitythead headers and tfoot footers.tbody for clearer structure, especially with thead.thead holds header rows with th. tbody holds data rows with td.tbody for striped backgrounds, bold text, or other body-level styles.Practice <tbody> with <thead> and CSS styling in the Try It editor.
6 people found this page helpful