Col

Struct Col 

Source
pub struct Col;
Expand description

The <col> element - defines a column within a table.

§Purpose

The <col> element defines a column or a group of columns within a table. Used inside <colgroup> to apply attributes and styles to entire columns without affecting individual cells. Provides a way to style columns collectively.

§Content Categories

  • None (only valid within <colgroup>)

§Permitted Content Model

  • None (void element)

§Common Use Cases

  • Setting column widths
  • Applying styles to specific columns
  • Defining visibility for individual columns
  • Grouping columns with shared formatting
  • Creating alternating column styles

§Key Attributes

  • span: Number of consecutive columns this element represents (default: 1)

§Example

<!-- Individual column styling -->
<table>
  <colgroup>
    <col class="name-column">
    <col class="data-column">
    <col class="data-column">
  </colgroup>
  <thead>
    <tr>
      <th>Name</th>
      <th>Value 1</th>
      <th>Value 2</th>
    </tr>
  </thead>
</table>

<!-- Using span attribute -->
<table>
  <colgroup>
    <col>
    <col span="2" class="numeric-columns">
    <col>
  </colgroup>
  <thead>
    <tr>
      <th>Product</th>
      <th>Price</th>
      <th>Quantity</th>
      <th>Notes</th>
    </tr>
  </thead>
</table>

<!-- Column widths -->
<table>
  <colgroup>
    <col style="width: 40%;">
    <col style="width: 30%;">
    <col style="width: 30%;">
  </colgroup>
  <thead>
    <tr>
      <th>Description</th>
      <th>Category</th>
      <th>Status</th>
    </tr>
  </thead>
</table>

§WHATWG Specification

Trait Implementations§

Source§

impl HtmlElement for Col

Source§

const TAG: &'static str = "col"

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

const VOID: bool = true

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

impl CanContain<Col> for Colgroup

Auto Trait Implementations§

§

impl Freeze for Col

§

impl RefUnwindSafe for Col

§

impl Send for Col

§

impl Sync for Col

§

impl Unpin for Col

§

impl UnwindSafe for Col

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.