<tbody> : Table Body element

Introduction

The <tbody> element in HTML represents the main body of a table where the rows of data are placed. It’s used to group the main content of the table apart from the header rows (contained within <thead>) and the footer rows (contained within <tfoot>, if present).

Here’s how you might use <tbody> in an HTML table:

Output :

In this example, we show the body section different form the other sections of the table by applying background colour on <tbody> and the <tbody> element contains multiple <tr> (table row) elements, each representing a row of data in the table. Each <tr> contains <td> (table data cell) elements, representing the actual data cells within each row.

Using <tbody> helps to semantically structure the table, making it clearer where the main content of the table lies, and it also assists in accessibility by separating the table’s data from its header and footer sections.

Leave a Comment