Tr

Struct Tr 

Source
pub struct Tr;
Expand description

The <tr> element - defines a row of cells in a table.

§Purpose

The <tr> element represents a row of cells in a table. Each row contains one or more <th> (header cell) or <td> (data cell) elements. Rows can be grouped within <thead>, <tbody>, and <tfoot> elements for semantic structure.

§Content Categories

  • None (only valid within <table>, <thead>, <tbody>, or <tfoot>)

§Permitted Content Model

  • Zero or more <td> or <th> elements
  • Optionally intermixed with script-supporting elements

§Common Use Cases

  • Creating rows of data in tables
  • Organizing tabular information horizontally
  • Building spreadsheet-like structures
  • Displaying lists of records
  • Creating pricing and comparison tables

§Key Attributes

  • Global attributes only

§Example

<!-- Basic table rows -->
<table>
  <thead>
    <tr>
      <th>Name</th>
      <th>Age</th>
      <th>City</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Alice</td>
      <td>30</td>
      <td>New York</td>
    </tr>
    <tr>
      <td>Bob</td>
      <td>25</td>
      <td>San Francisco</td>
    </tr>
  </tbody>
</table>

<!-- Row with mixed headers and data -->
<table>
  <tbody>
    <tr>
      <th scope="row">Product A</th>
      <td>$99</td>
      <td>In Stock</td>
    </tr>
    <tr>
      <th scope="row">Product B</th>
      <td>$149</td>
      <td>Out of Stock</td>
    </tr>
  </tbody>
</table>

<!-- Row with colspan -->
<table>
  <tr>
    <td colspan="3">Full width cell</td>
  </tr>
  <tr>
    <td>Cell 1</td>
    <td>Cell 2</td>
    <td>Cell 3</td>
  </tr>
</table>

<!-- Alternating row styles -->
<table>
  <tbody>
    <tr class="odd">
      <td>Row 1</td>
      <td>Data</td>
    </tr>
    <tr class="even">
      <td>Row 2</td>
      <td>Data</td>
    </tr>
  </tbody>
</table>

§WHATWG Specification

Trait Implementations§

Source§

impl HtmlElement for Tr

Source§

const TAG: &'static str = "tr"

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<Script> for Tr

Source§

impl CanContain<Td> for Tr

Source§

impl CanContain<Template> for Tr

Source§

impl CanContain<Th> for Tr

Source§

impl CanContain<Tr> for Table

Source§

impl CanContain<Tr> for Tbody

Source§

impl CanContain<Tr> for Tfoot

Source§

impl CanContain<Tr> for Thead

Auto Trait Implementations§

§

impl Freeze for Tr

§

impl RefUnwindSafe for Tr

§

impl Send for Tr

§

impl Sync for Tr

§

impl Unpin for Tr

§

impl UnwindSafe for Tr

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.