The HTML <tbody> tag defines the body section of a table, grouping the main data rows separately from the header and footer.
- Placed inside a <table> and contains <tr> (table rows) with <td> (data cells).
- Separates table data from <thead> (header) and <tfoot> (footer).
- Improves table structure, readability, and accessibility.
Syntax:
<tbody> // Table contents </tbody>
Attributes
- align: The align attribute sets the horizontal alignment of the content.
- valign: The valign attribute sets the vertical alignment of the content.
- char: The char attribute aligns content based on a specific character.
- charoff: The charoff attribute specifies the offset from the alignment character.
Note: These attributes were supported in HTML 4.01 but are not supported in HTML5.
Example: Using the <tbody> tag to group the body content of an HTML table. It contains rows with data for "Shashank" and "GeeksforGeeks" under "Name" and "User Id."