What elements are used for defining column headers?

Column headers in tables can be defined using the colspec element, which specifies the characteristics and properties of individual columns in the table. The colspec element defines the attributes and properties of each column in a DITA table, including column width, alignment, and more. Its key attributes are colname, colnum, and colwidth.

  • colname: This attribute specifies a unique name for the column. It is used to reference the column elsewhere in the table structure, such as in the entry elements of the table cells. The colname attribute is essential for identifying and associating headers with data cells.
  • colnum: The colnum attribute assigns a numerical value to the column. It typically starts from 1 for the first column, 2 for the second, and so on. The colnum value provides a sequential identifier for the columns within the table.
  • colwidth: This optional attribute allows for defining the width of the column. The width can be specified using measurements like percentages or fixed units (e.g., “20%” or “2in”). This attribute helps control the layout and presentation of the table.

          <title>Product Comparison</title>
          <tgroup cols="3">
            <colspec colname="col1" colnum="1" colwidth="20%"/>
            <colspec colname="col2" colnum="2" colwidth="30%"/>
            <colspec colname="col3" colnum="3" colwidth="50%"/>
                <entry colname="col1">Product</entry>
                <entry colname="col2">Features</entry>
                <entry colname="col3">Price</entry>
                <entry>Product A</entry>
                <entry>Feature set A</entry>
                <entry>Product B</entry>
                <entry>Feature set B</entry>

In this example:

  • Three columns are defined using colspec elements, each with a unique name, a numerical identifier, and a specified width.
  • The thead section contains a header row, where each entry element is associated with the appropriate column using the colname attribute.