Table body. The HTML <tbody> tag is used for grouping table rows along with <thead> and <tfoot>.

The <tbody> tag is used in conjunction with the <thead> tag and the <tfoot> tag in determining each part of the table (header, footer, body). Browsers can use this information to enable scrolling of the table body independently of the header and footer - particuarly useful for large tables. Also, when printing a large table that spans multiple pages, this information can enable the table header and footer to be printed at the top and bottom of each page.

tbody can be used more than once to separate different sections and must be used if <thead> and <tfoot> are used. It must be used within a table element and must follow both thead and tfoot elements when used.

Note: If you use the <tbody> tag, it must be used in the following context:

  • As a child of a <table> element, after any <caption>, <colgroup>, and <thead> elements, but only if there are no tr elements that are children of the <table> element.
  • The <tbody> tag can contain zero or more <tr> elements.

Required Attributes

  • None.

Optional Attributes

  • align can be used to horizontally align the cells within the element. The value can be left, center, right, justify or char.
  • valign can be used to vertically align the cells within the element. The value can be top, middle, bottom or baseline.
  • char can be used to specify a character with which cells will align, such as a decimal point. It is not supported by any major browser.
  • charoff can be used to specify the number of pixels the alignment should be offset from the char character. It is not supported by any major browser.
  • Common attributes

Example

<table>
	<thead>
		<tr>
			<th>Name</th>
			<th>Nationality</th>
		</tr>
	</thead>
	<tfoot>
		<tr>
			<td>Footer 1</td>
			<td>Footer 2</td>
		</tr>
	</tfoot>
	<tbody>
		<tr>
			<td>John</td>
			<td>English</td>
		</tr>
		<tr>
			<td>Pedro</td>
			<td>Portuguese</td>
		</tr>
	</tbody>
</table>

Changes in HTML5

  • None.

Related Tags