pub struct Colgroup;Expand description
The <colgroup> element - defines a group of columns in a table.
§Purpose
The <colgroup> element specifies a group of one or more columns in a table for formatting
purposes. It allows styling of entire columns without repeating styles on each cell. Can
contain <col> elements or use the span attribute to define column groups.
§Content Categories
- None (only valid within
<table>, after<caption>and before table rows)
§Permitted Content Model
- If
spanattribute is present: empty - Otherwise: zero or more
<col>elements
§Common Use Cases
- Styling multiple columns with shared characteristics
- Grouping related columns semantically
- Setting widths for multiple columns at once
- Applying background colors to column groups
- Defining visibility for column groups
§Key Attributes
span: Number of columns the group spans (if no<col>children)
§Example
<!-- Column group with span -->
<table>
<colgroup span="2" class="financial-data"></colgroup>
<colgroup></colgroup>
<thead>
<tr>
<th>Item</th>
<th>Price</th>
<th>Stock</th>
</tr>
</thead>
</table>
<!-- Column group with col elements -->
<table>
<colgroup>
<col class="name-col">
<col class="email-col">
</colgroup>
<colgroup>
<col class="role-col">
</colgroup>
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Role</th>
</tr>
</thead>
</table>
<!-- Styling column groups -->
<table>
<colgroup>
<col>
</colgroup>
<colgroup class="highlight">
<col span="2">
</colgroup>
<thead>
<tr>
<th>Product</th>
<th>Q1</th>
<th>Q2</th>
</tr>
</thead>
</table>§WHATWG Specification
Trait Implementations§
Source§impl HtmlElement for Colgroup
impl HtmlElement for Colgroup
impl CanContain<Col> for Colgroup
impl CanContain<Colgroup> for Table
impl CanContain<Template> for Colgroup
Auto Trait Implementations§
impl Freeze for Colgroup
impl RefUnwindSafe for Colgroup
impl Send for Colgroup
impl Sync for Colgroup
impl Unpin for Colgroup
impl UnwindSafe for Colgroup
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