HTML <tbody> Tag

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

What You’ll Learn

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.

01

Table Body

Group data rows.

02

thead + tbody

Headers vs data.

03

CSS Styling

Striped and bold rows.

04

Core Syntax

Inside table element.

05

Row Groups

thead, tbody, tfoot.

06

Best Practices

Semantic structure.

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

Valid HTML5 — Table Row Group

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.

📝 Syntax

Place tbody inside table and add tr rows with td or th cells:

syntax.html
<table>
  <tbody>
    <!-- Your table rows (tr) with data cells (td/th) here -->
  </tbody>
</table>

With thead Example

thead-tbody.html
<table>
  <thead>
    <tr>
      <th>Name</th>
      <th>Age</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>John</td>
      <td>25</td>
    </tr>
  </tbody>
</table>

Syntax Rules

  • tbody must be a direct child of table (along with caption, colgroup, thead, and tfoot).
  • Only tr elements go directly inside tbody.
  • Place thead before tbody and tfoot after tbody in source order.
  • A table may contain multiple tbody elements for separate row groups.

⚡ Quick Reference

TopicCode SnippetNotes
Basic tbody<tbody>...</tbody>Row group
With theadthead + tbodyHeader + data
Child rows<tr><td>...</td></tr>Data cells
CSS classclass="striped-table"Body styling
vs theadtbody = datathead = headers
Browser supportUniversalAll browsers

⚖️ <thead>, <tbody>, and <tfoot>

ElementContainsTypical cells
<thead>Header rowsth column labels
<tbody>Main data rowstd data values
<tfoot>Footer / summary rowsTotals, averages
Order in HTMLtheadtbodytfootSemantic grouping

🧰 Attributes

The <tbody> tag has no tag-specific attributes. Use global attributes for styling and scripting hooks.

attributes.html
<tbody class="striped-table">
  <!-- Your table rows (tr) with data cells (td/th) here -->
</tbody>
class / id Global

Target all body rows for striped backgrounds or emphasis.

class="striped-table"
style Global

Inline styles on tbody affect the row group container.

style="background: #f8fafc"
lang Optional

Declare language when body cell text differs from the page.

lang="en"
align / valign Obsolete

Deprecated presentational attributes. Use CSS on td and th instead.

text-align: left

Examples Gallery

Structured tabular data, striped body styling, and highlighted rows with copy-ready code and live previews.

👀 Live Preview

Table with thead headers and tbody data rows:

NameAge
John25
Mary30

📚 Common Use Cases

Use <tbody> to structure tabular data, separate headers from body content, and apply body-level styling.

Structuring Tabular Data

The primary purpose of tbody is organizing the main body of tabular data, separate from thead and tfoot:

structuring-tabular-data.html
<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>
Try It Yourself

Adding Style and Classes

Apply a class to tbody for striped or background styling on all body rows:

adding-style-and-classes.html
<tbody class="striped-table">
  <tr>
    <td>John</td>
    <td>25</td>
  </tr>
</tbody>
Try It Yourself

Highlighted Body Rows

Use a class on tbody to emphasize all data cells in the body section:

highlighted-rows.html
<tbody class="highlighted-rows">
  <tr>
    <td>Alice</td>
    <td>25</td>
  </tr>
</tbody>
Try It Yourself

♿ Accessibility

  • Pair tbody with thead — Header rows in thead give context to tbody data cells.
  • Use th in thead — Column labels belong in thead, not mixed into tbody unless using row headers.
  • Add a caption — A caption describes the whole table including its body data.
  • Keep tables for data — Do not use tbody in layout tables; it confuses assistive technologies.

🧠 How <tbody> Works

1

Author groups data rows

Main tr rows with td cells go inside tbody.

Markup
2

Browser separates sections

thead headers and tbody data render as distinct row groups.

Structure
3

CSS styles the body

Classes on tbody target all body rows for stripes or emphasis.

Design
=

Organized table body

Data rows are semantically grouped, styled, and easier to maintain.

Browser Support

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

Baseline · HTML4 / HTML5

Table body everywhere

All browsers render <tbody> as the standard table row group.

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
<tbody> tag 100% supported

Bottom line: Use <tbody> confidently to group table data rows in any browser.

Conclusion

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.

💡 Best Practices

✅ Do

  • Use tbody with thead for structured tables
  • Apply CSS classes to tbody for striped or bold styling
  • Keep header rows in thead, data rows in tbody
  • Write explicit tbody for clearer, maintainable markup

❌ Don’t

  • Mix column headers into tbody without reason
  • Use obsolete align or valign on tbody
  • Place tbody outside of table
  • Use tables (and tbody) for page layout

Key Takeaways

Knowledge Unlocked

Six truths every developer should know about <tbody>

Bookmark these before you structure your next HTML table.

6
Core concepts
📑 02

thead

Header section.

Pairing
🎨 03

CSS Class

Striped rows.

Styling
⚖️ 04

vs tfoot

Data vs footer.

Comparison
05

Semantic

Clear structure.

A11y
🌐 06

100% Support

All browsers.

Compatibility

❓ Frequently Asked Questions

It groups the main data rows of a table, separate from thead headers and tfoot footers.
Browsers create an implicit tbody if omitted. Use explicit tbody for clearer structure, especially with thead.
thead holds header rows with th. tbody holds data rows with td.
Yes. Add classes to tbody for striped backgrounds, bold text, or other body-level styles.
Yes. Full support in every major browser including Internet Explorer.

Group your table body rows

Practice <tbody> with <thead> and CSS styling in the Try It editor.

Try thead + tbody example →

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