HTML table body - how to use <tbody> tag

The HTML <tbody> tag is used to define body content in a table. The <tbody> tag is used together with <tfoot> and <thead> tags to define appropriate parts of the table.

The <tbody> tag is placed within a <table> tag after any <caption>, <colgroup>, <thead>, but before <tfoot> tags.

The <tbody> tag needs to have one or more <tr> tags.

Attributes

The tbody tag supports the global and event attributes.

Defines the

Examples:

<table border="1"> <thead> <tr> <th>Country</th> <th>Capital</th> <th>City</th> </tr> </thead> <tbody> <tr> <td>China</td> <td>Beijing</td> <td>Shanghai</td> </tr> <tr> <td>India</td> <td>New Delhi</td> <td>Hyderabad</td> </tr> </tbody> <tfoot> <tr> <td>Table</td> <td>Ends</td> <td>Here</td></tr> </tfoot> </table>

Related HTML tags and Useful Links:

  • <table> - used to define a table
  • <thead> - used to define header of the table
  • <tbody> - used to define the table body
  • <tfoot> - used to define footer of the table
  • <th> - used to define header cells
  • <tr> - used to define table row
  • <td> - used to define the cell of the table
  • <caption> - used to define caption / title of the table
  • <col> - used to define properties of columns defined within the <colgroup> tag
  • <colgroup> - used to group one or more columns
  • Learn more about HTML table