Class Colgroup<T extends Colgroup<T>>


public class Colgroup<T extends Colgroup<T>> extends StyledElement<T>
Represents an HTML <colgroup> element for grouping table columns.

The Colgroup element specifies a group of one or more columns in a table for formatting. It must be a child of a Table element, after any <caption> elements and before any <thead>, <tbody>, <tfoot>, and <tr> elements.

The <colgroup> element restricts its content to Col elements only. Use addCol(Col) to add column definitions.

Features:

  • Groups table columns for styling
  • Can contain col elements
  • Span attribute for simple column grouping
  • Useful for applying styles to column groups

Usage:


 // Simple column group with span
 Colgroup colgroup = new Colgroup(3);

 // Column group with individual col elements
 Colgroup colgroup = new Colgroup();
 colgroup.addCol(new Col());
 colgroup.addCol(new Col());
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Colgroup

      public Colgroup()
      Constructs an empty <colgroup> element.
    • Colgroup

      public Colgroup(int span)
      Constructs a <colgroup> element spanning multiple columns.
      Parameters:
      span - the number of columns in the group
  • Method Details

    • setSpan

      public final T setSpan(int colspan)
      Sets the number of columns in the group.
      Parameters:
      colspan - the number of columns to span
    • addCol

      public void addCol(Col col)
      Adds a Col element to this column group.
      Parameters:
      col - the Col element to add
    • removeAllElements

      public void removeAllElements()
      Removes all col elements from this column group.
      Overrides:
      removeAllElements in class Element<T extends Colgroup<T>>