HTML tbody Tag Interactive Tutorial Text Version
The <tbody> tag groups the body rows of a table. Use <thead> for header rows, <tbody> for data rows, <tfoot> for footer. Order: caption, thead, tbody, tfoot. If you omit <tbody>, the browser creates an implicit one.
<tbody>
Example: <table><thead><tr><th>Name</th></tr></thead><tbody><tr><td>Alice</td></tr></tbody></table>. <tbody> contains one or more <tr> with <td> cells. You can have multiple <tbody> to group rows.
<table>
<thead><tr><th>Name</th></tr></thead>
<tbody><tr><td>Alice</td></tr></tbody>
</table>
Semantics: thead = header, tbody = body data, tfoot = footer. Using them improves accessibility and styling. Screen readers use this structure. Always put tbody after thead and before tfoot.
<table>
<thead><tr><th>Col</th></tr></thead>
<tbody><tr><td>Data</td></tr></tbody>
</table>
In the browser, thead rows and tbody rows render together. Styling can target tbody tr for zebra stripes or hover. Prefer explicit thead/tbody for clarity.
<table><thead><tr><th>Name</th></tr></thead><tbody><tr><td>Alice</td></tr></tbody></table>
Checkpoint: Which element wraps the body (data) rows of a table?
<tbody>
Correct! <tbody> wraps body rows; <thead> wraps header rows. Use both for clear structure and accessibility.
<tbody><tr><td>Data</td></tr></tbody>
You now know tbody structure. Complete the challenges below to master the <tbody> tag!