pub struct Tbody;Expand description
The <tbody> element - groups body content rows in a table.
§Purpose
The <tbody> element groups one or more <tr> elements as the body section of a table.
It represents the main data content, as opposed to headers (<thead>) and footers (<tfoot>).
Allows applying styles and behavior to the table body separately from headers and footers.
§Content Categories
- None (only valid within
<table>)
§Permitted Content Model
- Zero or more
<tr>elements
§Common Use Cases
- Separating table data from headers and footers
- Applying styles to the table body
- Enabling independent scrolling of table body
- Grouping data rows semantically
- Creating multiple body sections in complex tables
§Key Attributes
- Global attributes only
§Example
<!-- Basic table body -->
<table>
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>Alice</td>
<td>30</td>
</tr>
<tr>
<td>Bob</td>
<td>25</td>
</tr>
</tbody>
</table>
<!-- Multiple tbody sections -->
<table>
<thead>
<tr>
<th>Product</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2"><strong>Electronics</strong></td>
</tr>
<tr>
<td>Laptop</td>
<td>$999</td>
</tr>
</tbody>
<tbody>
<tr>
<td colspan="2"><strong>Clothing</strong></td>
</tr>
<tr>
<td>T-Shirt</td>
<td>$20</td>
</tr>
</tbody>
</table>
<!-- Scrollable table body -->
<table>
<thead>
<tr>
<th>Date</th>
<th>Event</th>
</tr>
</thead>
<tbody style="display: block; max-height: 200px; overflow-y: scroll;">
<tr>
<td>2024-01-01</td>
<td>New Year</td>
</tr>
<!-- More rows... -->
</tbody>
</table>§WHATWG Specification
Trait Implementations§
Source§impl HtmlElement for Tbody
impl HtmlElement for Tbody
impl CanContain<Script> for Tbody
impl CanContain<Tbody> for Table
impl CanContain<Template> for Tbody
impl CanContain<Tr> for Tbody
Auto Trait Implementations§
impl Freeze for Tbody
impl RefUnwindSafe for Tbody
impl Send for Tbody
impl Sync for Tbody
impl Unpin for Tbody
impl UnwindSafe for Tbody
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more