HTML <tbody> tag

Updated: 11/13/2018 by Computer Hope
HTML tbody tag

When writing in HTML, the <tbody> tag is used to designate the section of a table that contains all of the data cells. It is useful for sectioning off parts of the table to be styled with CSS. The following sections contain information about the <tbody> tag, including an example of it in use, as well as related attributes and browser compatibility.

Tip

More advanced tables may also include the <caption>, <col>, <colgroup>, <tfoot>, or <thead> elements.

Tip

Browsers may use the <tbody> element to enable the scrolling of a table body independently of the header and footer sections.

Example of <tbody> code

<table class="mtable2 tab">
<thead>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
</thead>
<tbody>
<tr class="tcw">
<td>March</td>
<td>$200</td>
</tr>
<tr class="tcw">
<td>April</td>
<td>$300</td>
</tr>
<tr class="tcw">
<td>May</td>
<td>$250</td>
</tr>
</tbody>
<tfoot>
<tr class="tcw">
<td>Total</td>
<td>$750</td>
</tr>
<tfoot>
</table>

Example result

Month Savings
March $200
April $300
May $250
Total $750

We have added a few of our own classes to the table using CSS; this action allows us to improve its appearance.

Deprecated attributes

Within an HTML tag, an attribute dictates certain aspects of an HTML element. Attributes are made up of a name and value pair; all tags support standard attributes. Every attribute that was unique to the <tbody> tag is deprecated. While these attributes may work with the some versions of HTML, they will eventually be phased out. You should use CSS to adjust the dimensions and appearance of this element.

Attribute Description
align Designates the alignment of content inside an element.
char Aligns the content in a <tbody> element to a specific character.
charoff Sets the number of characters to offset the content from the character designated by the char attribute.
valign Alights the content in a <tbody> element vertically.

Compatibility

Edge Internet Explorer Firefox Safari Opera Chrome
All versions All versions All versions All version All versions All versions

Browser, Cell, Class, Column, Compatibility, Format, Row, <table>, <tfoot>, <thead>, Web design terms