Can table headers span multiple rows or columns?

In DITA, table headers can span multiple rows or columns to provide a clear and structured representation of tabular data, especially when dealing with complex or structured information.

Spanning Rows:

When a header cell spans multiple rows, it indicates that it applies to a group of rows below it. This is commonly used for labeling categories or subheadings that encompass several rows of data.

To span rows, use the morerows attribute with the entry element. The morerows attribute specifies the number of additional rows the header cell should span.


        <table>
          <title>Monthly Sales Data</title>
          <tgroup cols="3">
            <colspec colname="col1" colnum="1"/>
            <colspec colname="col2" colnum="2"/>
            <colspec colname="col3" colnum="3"/>
            <thead>
              <row>
                <entry>Month</entry>
                <entry>Product</entry>
                <entry>Revenue</entry>
              </row>
              <row>
                <entry>January</entry>
                <entry>Product A</entry>
                <entry morerows="1">$$</entry>
              </row>
              <row>
                <entry> </entry>
                <entry>Product B</entry>
                <entry>$$</entry>
              </row>
            </thead>
            <tbody>
              <!-- Data rows... -->
            </tbody>
          </tgroup>
        </table>
    

Spanning Columns:

When a header cell spans multiple columns, it indicates that it applies to a group of columns to the right. This is useful to label a group of related data columns.

To span columns, use the namest and nameend attributes with the entry element. namest specifies the name of the first column the header cell spans, and nameend specifies the name of the last column it spans.


        <table>
          <title>Product Features</title>
          <tgroup cols="4">
            <colspec colname="col1" colnum="1"/>
            <colspec colname="col2" colnum="2"/>
            <colspec colname="col3" colnum="3"/>
            <colspec colname="col4" colnum="4"/>
            <thead>
              <row>
                <entry>Feature</entry>
                <entry>Specifications</entry>
                <entry namest="col3" nameend="col4">Compatibility</entry>
              </row>
            </thead>
            <tbody>
              <!-- Data rows... -->
            </tbody>
          </tgroup>
        </table>