Skip to main content

What are the main elements that make up the structure of a table?

The structure of an HTML table consists of several basic elements, each responsible for a specific part of the table.


1. <table> - table container

This is the main tag that contains all the other table elements.

html
<table> ... </table>

2. <tr> - table row

Each table row is wrapped in a <tr> tag. It contains data cells (<td>) or header cells (<th>).

html
<tr> <td>Cell 1</td> <td>Cell 2</td> </tr>

3. <td> - table data

Used for regular cells that hold text, numbers, images, and so on.

html
<td>Sample data</td>

4. <th> - table header

Used for column or row headers. Text inside <th> is usually bold and centered by default.

html
<th>Name</th>

5. <thead> - table header section

Contains one or more <tr> rows with headers (<th>). It helps logically separate the table's "head".

html
<thead> <tr> <th>Name</th> <th>Age</th> </tr> </thead>

6. <tbody> - table body

Contains the table's main data (<tr> rows with <td> cells).

html
<tbody> <tr> <td>Maria</td> <td>25</td> </tr> </tbody>

Used for rows with totals or notes. It is usually placed at the bottom, but browsers may visually render it after <tbody>.

html
<tfoot> <tr> <td>Total</td> <td>100</td> </tr> </tfoot>

Summary structure:

html
<table> <thead> <tr> <th>Item</th> <th>Price</th> </tr> </thead> <tbody> <tr> <td>Bread</td> <td>$40</td> </tr> <tr> <td>Milk</td> <td>$70</td> </tr> </tbody> <tfoot> <tr> <td>Total</td> <td>$110</td> </tr> </tfoot> </table>

In brief:

ElementPurpose
<table>The whole table
<tr>Row
<th>Header cell
<td>Regular cell
<thead>Top part (headers)
<tbody>Main data
<tfoot>Totals/bottom of the table

Conclusion: The basic structure of an HTML table consists of: <table><thead><tbody><tfoot><tr><th>/<td>. These elements form a logically correct and semantically clear table.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.