Code has been added to clipboard!

HTML tbody Tag

Reading time 2 min
Published Jun 29, 2017
Updated Oct 11, 2019

HTML tbody: Main Tips

  • HTML tbody tags are used to turn a set of table rows into a table.
  • A tbody element must contain at least one <tr> element.
  • This element is used together with <thead> and <tfoot> tags.
  • The table layout will not be affected by <tfoot>, <tbody>, <thead> elements. Style it using CSS.

Using the tbody Tag

HTML tbody tags define the data rows it contains as a table:

Example
<table>
 <tbody>
  <tr>
    <td>Long Island</td>
    <td>45</td>
    <td>50</td>
  </tr>
  <tr>
    <td>Geeky stuff</td>
    <td>85</td>
    <td>90</td>
  </tr>
  <tr>
    <td>StayAtHomeMart</td>
    <td>25</td>
    <td>30</td>
  </tr>
  <tr>
    <td>BestBuy</td>
    <td>60</td>
    <td>10</td>
  </tr>
 </tbody>
</table>

If the table includes a <thead> element, <tbody> has to be placed after it.

All table rows except footers and headers must be contained in a tbody element. You cannot have <tr> elements that are descendants of the <table> but aren't wrapped in tbody tags.

Note: you can use multiple tbody elements in a table to divide rows into sections. However, they must be consecutive.

Default CSS Settings

The <tbody> element will be displayed with these default values by most browsers:

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

Deprecated tbody Tag Attributes

There were four tag attributes you could use with HTML tbody tags. However, they have been deprecated in HTML4.01 and removed completely in HTML5. Get to know them, but don't use them in your codes.

align defined the alignment of the content inside the <tbody> element:

Example
<tbody align="right">

Note: instead of align, use CSS text-align property.

char set the alignment of the content inside the <tbody> element to a character:

Example
<tbody align="char" char=".">

charoff specified the number of characters to offset the content from the character defined by char:

Example
<tbody align="char" char="." charoff="2">

valign vertically aligned the <tbody> element content:

Example
<tbody valign="bottom">

Note: instead of valign, use CSS vertical-align property.

Browser support

Chrome
1+
Edge
All
Firefox
1+
IE
All
Opera
All
Safari
All

Mobile browser support

Chrome
All
Firefox
4+
Opera
All
Safari
All
Basics
Introduction
Syntax
Editors
Basic Examples
Head Section
<!DOCTYPE>
Tags and Elements
Semantic Elements
Tags Reference
Attributes
Comments
Block and Inline Elements
Forms
Form Elements
Input
Responsive Web Design
Inline Scripts
Uniform Resource Locator
Redirect
XHTML
Geolocation
Drag and Drop
Local Storage
Web Workers
Server-Sent Events
Character Encoding
Text Formatting
Quotation and Citation Elements
Headings
Paragraphs
Links
Tables
Lists
Symbols
Space
Tab
Styles
Computer Code
Layout
Classes
Colors
Images
iframes
Audio Player
Video Player
YouTube Videos
Multimedia
Canvas
SVG
<!-- -->
<a>
<abbr>
<acronym> DEPRECATED
<address>
<applet> DEPRECATED
<article>
<aside>
<audio>
<b>
<base>
<basefont> DEPRECATED
<bdi>
<bdo>
<big> DEPRECATED
<blink> DEPRECATED
<blockquote>
<body>
<br>
<button>
<canvas>
<caption>
<center> DEPRECATED
<cite>
<code>
<col>
<colgroup>
<datalist>
<dd>
<del>
<details>
<dfn>
<dialog>
<dir> DEPRECATED
<div>
<dl>
<dt>
<em>
<embed>
<fieldset>
<figcaption>
<figure>
<font> DEPRECATED
<footer>
<form>
<frame> DEPRECATED
<frameset> DEPRECATED
<h1> – <h6>
<head>
<header>
<hr>
<html>
<i>
<iframe>
<img>
<input>
<ins>
<kbd>
<keygen> DEPRECATED
<label>
<legend>
<li>
<link>
<main>
<map>
<mark>
<menu>
<menuitem> DEPRECATED
<meta>
<meter>
<nav>
<noframes> DEPRECATED
<noscript>
<object>
<ol>
<optgroup>
<option>
<output>
<p>
<param>
<pre>
<progress>
<q>
<rp>
<rt>
<ruby>
<s>
<samp>
<script>
<section>
<select>
<small>
<source>
<span>
<strike> DEPRECATED
<strong>
<style>
<sub>
<summary>
<sup>
<table>
<tbody>
<td>
<tfoot>
<th>
<thead>
<time>
<title>
<tr>
<track>
<tt> DEPRECATED
<u>
<ul>
<var>
<video>
<wbr>