HTML <tbody> Tag

Beginner
6 min read
Updated: Nov 2026
4 examples
Live preview

Definition and Usage

The <tbody> element groups the main data rows of a <table>. Those rows are <tr> elements with <td> or <th> cells.

Pair it with <thead> for column headers and <tfoot> for totals or notes. Explicit groups help CSS, printing, and assistive technologies. You may use more than one consecutive <tbody> to split large tables into sections.

Baseline · Widely available.

Not deprecated. Core tbody support has been stable across browsers since about July 2015 (and much earlier in practice).

Deprecated attributes.

Do not use align, bgcolor, char, charoff, or valign on <tbody>. Prefer CSS text-align, background-color, and vertical-align.

Implicit tbody.

If you put <tr> directly under <table>, the browser wraps them in a <tbody>. That is why table > tr often matches nothing.

HTML Syntax

syntax.html
<tbody> tr rows</tbody>

Place <tbody> inside <table>, after any <caption>, <colgroup>, and <thead>. Content is zero or more <tr> rows. Start/end tags may be omitted in some cases, but writing them is clearer for learners.

Attributes

Modern <tbody> has no current element-specific attributes — only global attributes. These older attributes are deprecated (shown for migration):

AttributeDescriptionTry it
alignDeprecated — use CSS text-align insteadTry it
bgcolorDeprecated — use CSS background-color insteadTry it
valignDeprecated — use CSS vertical-align insteadTry it
char / charoffDeprecated — use CSS text-align (and tabular numerals) insteadTry it

Global Attributes

The <tbody> tag also supports the Global Attributes in HTML.

Live Preview

Switch datasets inside a real <tbody> and compare one body vs two bodies.

A real table with <thead> and <tbody>. Multiple bodies must be consecutive.

Table
Course roster
NameScore
Ada92
Grace88

One <tbody> with 2 data rows

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Basic tbody with thead

Put column headers in <thead> and the data rows in <tbody>.

HTML
<table>
  <thead>
    <tr>
      <th scope="col">Student</th>
      <th scope="col">Major</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Ada</td>
      <td>Math</td>
    </tr>
    <tr>
      <td>Grace</td>
      <td>CS</td>
    </tr>
  </tbody>
</table>
Try It Yourself

How It Works

  1. Open <table> as the root container.
  2. Add <thead> with one header row of <th> cells.
  3. Wrap data rows in <tbody>. Each <tr> is one record.
  4. Style or script the body with tbody selectors without touching the header.

Example 2 — tbody with tfoot

Keep totals in <tfoot> while the main values stay in <tbody>.

HTML
<table>
  <caption>Council budget</caption>
  <thead>
    <tr>
      <th scope="col">Item</th>
      <th scope="col">Cost</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">Stationery</th>
      <td>18,000</td>
    </tr>
    <tr>
      <th scope="row">Snacks</th>
      <td>3,000</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <th scope="row">Total</th>
      <td>21,000</td>
    </tr>
  </tfoot>
</table>
Try It Yourself

How It Works

  1. Caption names the table for everyone, including screen readers.
  2. thead holds column labels; tbody holds each item.
  3. tfoot holds the summary row that belongs with the table.
  4. Semantics: header/body/footer stay distinct for print and assistive tech.

Example 3 — Multiple tbody Sections

Use consecutive <tbody> blocks to group rows by category (only one thead per table).

HTML
<table>
  <thead>
    <tr>
      <th scope="col">ID</th>
      <th scope="col">Name</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th colspan="2" scope="colgroup">Computer Science</th>
    </tr>
    <tr>
      <td>101</td>
      <td>Ada</td>
    </tr>
  </tbody>
  <tbody>
    <tr>
      <th colspan="2" scope="colgroup">Physics</th>
    </tr>
    <tr>
      <td>202</td>
      <td>Marie</td>
    </tr>
  </tbody>
</table>
Try It Yourself

How It Works

  1. One thead for the whole table’s column labels.
  2. Each tbody is a consecutive section of related rows.
  3. Section title row can use <th colspan="…"> inside that body.
  4. Keep bodies consecutive so the browser does not “fix” misplaced groups.

Example 4 — Implicit tbody

Rows under <table> still get a body in the DOM. Prefer writing <tbody> yourself.

HTML
<!-- You write: -->
<table>
  <tr><td>Ada</td><td>92</td></tr>
  <tr><td>Grace</td><td>88</td></tr>
</table>

<!-- Browser effectively builds: -->
<table>
  <tbody>
    <tr><td>Ada</td><td>92</td></tr>
    <tr><td>Grace</td><td>88</td></tr>
  </tbody>
</table>
Try It Yourself

How It Works

  1. Author omits tbody and places tr under table.
  2. The parser inserts tbody around those rows.
  3. table > tr fails because tr is not a direct child anymore.
  4. Best habit: write <tbody> yourself so structure matches your CSS and mental model.

Edge Cases & Pitfalls

Most tbody surprises come from implicit wrappers, order rules, or presentational attributes.

selectors

Avoid table > tr

Implicit tbody breaks child combinators. Prefer tbody tr or table tr.

order

Keep sections in valid order

After caption/colgroup: thead, then body/footer groups. Multiple tbody elements must be consecutive.

limits

Only one thead / tfoot

You can have many tbody sections, but only one thead and one tfoot per table.

attrs

Skip deprecated align / bgcolor

Style the body with CSS. Presentational attributes on tbody are obsolete.

semantics

Do not fake layout with tbody

tbody groups tabular data rows. Page layout still belongs to CSS Grid or Flexbox.

Browser Support

The <tbody> element is core HTML table markup in every browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

<tbody>

Widely available since about July 2015 (and long before). Browsers also insert an implicit tbody when rows sit directly under table.

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
<tbody> Widely supported

Bottom line: Safe to use everywhere. Write tbody explicitly, style with CSS, and remember the implicit wrapper when debugging selectors.

Key Takeaways

  • Role: <tbody> groups the table’s main data rows.
  • Partners: use with thead and optional tfoot.
  • Multiple: consecutive tbody sections can split categories.
  • DOM tip: browsers may insert tbody for you — write it anyway.

One line: put data rows in <tbody> (and headers in <thead>) so the table’s body is clear.

Default CSS Settings

Typical user-agent styling for tbody (simplified; exact rules vary by browser):

default.css
tbody {
  display: table-row-group;
  vertical-align: middle;
  border-color: inherit;
}

Style body rows with selectors like tbody tr:nth-child(even). Remember an implicit tbody exists even when you omit the tags.

Frequently Asked Questions

The tbody element groups the main data rows of a table. It sits with thead (column headers) and tfoot (summary rows) to mark clear table sections.
Not always in markup. If you put tr elements directly under table, the browser inserts a tbody for you. Writing tbody yourself makes structure and CSS clearer.
Yes. Consecutive tbody elements can split a large table into sections (for example by category). A table may have only one thead and one tfoot.
Inside table, after any caption, colgroup, and thead. Put tfoot after thead as well; browsers still show the footer at the bottom.
Because bare rows under table are wrapped in an implicit tbody. Prefer selectors like tbody tr or table tr instead of table > tr.
No. Those attributes are deprecated. Style the body with CSS such as background-color, text-align, and vertical-align.

Next: td

Learn the standard data cell used inside table rows.

td tutorial →

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.

12 people found this page helpful