Class Th


@Marshalled(typeName="th") public class Th extends HtmlElementMixed<Th>
DTO for an HTML <th> element.

The th element represents a header cell in a table. It is used to contain header information for a column or row, providing context and meaning to the data cells (td) in the table. The th element supports various attributes for accessibility, spanning multiple columns or rows, and defining the relationship between header and data cells.

Examples:

import static org.apache.juneau.bean.html5.HtmlBuilder.*; // Simple header cell Th simple = th("Name"); // Header cell with scope Th scoped = th("Age") .scope("col"); // Header cell spanning multiple columns Th colspan = th("Contact Information") .colspan(2); // Header cell with abbreviation Th abbreviated = th("Quantity") .abbr("Qty"); // Header cell with sorting Th sorted = th("Price") .sorted("asc"); // Header cell with styling Th styled = th("Status") .class_("header-cell"); // Header cell with complex content Th complex = th( .children( new Strong().children("Total"), " ", new Small().children("(USD)") );

See Also:
  • Constructor Details

    • Th

      public Th()
      Creates an empty Th element.
    • Th

      public Th(Object... children)
      Creates a Th element with the specified child nodes.
      Parameters:
      children - The child nodes. Must not be null.
  • Method Details

    • abbr

      public Th abbr(String value)
      abbr attribute.

      Specifies an alternative, abbreviated label for the header cell. This is used by screen readers and other assistive technologies when referencing the cell in other contexts.

      The abbreviation should be shorter than the full header text but still meaningful.

      Parameters:
      value - The abbreviated label for the header cell. Can be null to unset the attribute.
      Returns:
      This object.
    • colspan

      public Th colspan(Object value)
      colspan attribute.

      Number of columns that the cell is to span.

      Parameters:
      value - The new value for this attribute. Typically a Number or String. Can be null to unset the attribute.
      Returns:
      This object.
    • headers

      public Th headers(String value)
      headers attribute.

      Specifies the IDs of header cells that apply to this table cell. This creates a programmatic relationship between the cell and its headers for accessibility purposes.

      Multiple IDs can be specified as a space-separated list.

      Parameters:
      value - The IDs of header cells that apply to this cell. Can be null to unset the attribute.
      Returns:
      This object.
    • rowspan

      public Th rowspan(Object value)
      rowspan attribute.

      Number of rows that the cell is to span.

      Parameters:
      value - The new value for this attribute. Typically a Number or String. Can be null to unset the attribute.
      Returns:
      This object.
    • scope

      public Th scope(String value)
      scope attribute.

      Specifies which cells the header cell applies to. This helps define the relationship between header and data cells for accessibility.

      Possible values:

      • "row" - Header applies to all cells in the same row
      • "col" - Header applies to all cells in the same column
      • "rowgroup" - Header applies to all cells in the same row group
      • "colgroup" - Header applies to all cells in the same column group
      Parameters:
      value - Which cells the header cell applies to. Can be null to unset the attribute.
      Returns:
      This object.
    • sorted

      public Th sorted(String value)
      sorted attribute.

      Specifies the sort direction and ordinality of the column. This indicates how the table is currently sorted and which column is the primary sort key.

      Common values:

      • "asc" - Column is sorted in ascending order
      • "desc" - Column is sorted in descending order
      • "asc 1" - Column is the primary sort key in ascending order
      • "desc 1" - Column is the primary sort key in descending order
      Parameters:
      value - The sort direction and ordinality of the column. Can be null to unset the attribute.
      Returns:
      This object.