Colgroup

Struct Colgroup 

Source
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 span attribute 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

Source§

const TAG: &'static str = "colgroup"

The HTML tag name (e.g., “div”, “span”, “img”).
Source§

const VOID: bool = false

Whether this is a void element (self-closing, no children allowed).
Source§

impl CanContain<Col> for Colgroup

Source§

impl CanContain<Colgroup> for Table

Source§

impl CanContain<Template> for Colgroup

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.