pub struct Thead;Expand description
The <thead> element - groups header rows in a table.
§Purpose
The <thead> element groups one or more <tr> elements that contain table headers.
It defines the header section of a table, typically containing column labels. Browsers
can use this to enable scrolling of the table body independently of the header, and to
repeat headers when printing multi-page tables.
§Content Categories
- None (only valid within
<table>)
§Permitted Content Model
- Zero or more
<tr>elements
§Common Use Cases
- Defining column headers for tables
- Creating sticky headers that remain visible while scrolling
- Enabling header repetition in printed tables
- Semantically separating headers from data
- Styling table headers distinctly from data
§Key Attributes
- Global attributes only
§Example
<!-- Basic table header -->
<table>
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Role</th>
</tr>
</thead>
<tbody>
<tr>
<td>John Doe</td>
<td>john@example.com</td>
<td>Developer</td>
</tr>
</tbody>
</table>
<!-- Multi-row header -->
<table>
<thead>
<tr>
<th rowspan="2">Name</th>
<th colspan="2">Contact</th>
</tr>
<tr>
<th>Email</th>
<th>Phone</th>
</tr>
</thead>
<tbody>
<tr>
<td>Alice</td>
<td>alice@example.com</td>
<td>555-0001</td>
</tr>
</tbody>
</table>
<!-- Sticky header -->
<table>
<thead style="position: sticky; top: 0; background: white;">
<tr>
<th>Product</th>
<th>Price</th>
<th>Stock</th>
</tr>
</thead>
<tbody>
<tr>
<td>Widget</td>
<td>$10</td>
<td>50</td>
</tr>
<!-- Many more rows... -->
</tbody>
</table>§Accessibility
- Use
<th>elements within<thead>for proper header semantics - Add
scopeattributes to header cells for complex tables - Ensure header text is descriptive and concise
§WHATWG Specification
Trait Implementations§
Source§impl HtmlElement for Thead
impl HtmlElement for Thead
impl CanContain<Script> for Thead
impl CanContain<Template> for Thead
impl CanContain<Thead> for Table
impl CanContain<Tr> for Thead
Auto Trait Implementations§
impl Freeze for Thead
impl RefUnwindSafe for Thead
impl Send for Thead
impl Sync for Thead
impl Unpin for Thead
impl UnwindSafe for Thead
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