How are header rows and columns marked in DITA tables?

In DITA, header rows and columns in tables are marked using specific DITA elements to distinguish them from regular content rows and columns. This markup is essential to identify which rows and columns contain headers and provide additional context to the tabular data.

Header Rows:

Header rows are used to label or describe the data in columns and provide context for the table. They are typically placed at the beginning of a table. In DITA, header rows are marked using the <row> element within the <thead> element. Each <entry> within the <row> represents a header cell.

Example:


        <table>
            <title>Employee Information</title>
            <tgroup cols="3">
                <colspec colname="col1" colnum="1"/>
                <colspec colname="col2" colnum="2"/>
                <colspec colname="col3" colnum="3"/>
                <!-- Table header row -->
                <thead>
                    <row>
                        <entry>Employee ID</entry>
                        <entry>Name</entry>
                        <entry>Department</entry>
                    </row>
                </thead>
                <!-- Table body rows -->
                <tbody>
                    <row>
                        <entry>101</entry>
                        <entry>John Doe</entry>
                        <entry>HR</entry>
                    </row>
                    <!-- More rows... -->
                </tbody>
            </tgroup>
        </table>
    

Header Columns:

Header columns label or describe the content in rows and provide context for the table’s data. They are typically placed at the beginning of a table. In DITA, header columns are marked using the <colspec> elements with appropriate attributes. Each <colspec> specifies a column’s characteristics, including whether it is a header column.

Example:


        <table>
            <title>Product Comparison</title>
            <tgroup cols="4">
                <!-- Define column specifications, marking the first column as a header -->
                <colspec colname="col1" colnum="1" colwidth="15%"/>
                <colspec colname="col2" colnum="2"/>
                <colspec colname="col3" colnum="3"/>
                <colspec colname="col4" colnum="4"/>
                <!-- Table header row -->
                <thead>
                    <row>
                        <entry>Features</entry>
                        <entry>Product A</entry>
                        <entry>Product B</entry>
                        <entry>Product C</entry>
                    </row>
                </thead>
                <!-- Table body rows -->
                <tbody>
                    <row>
                        <entry>Price</entry>
                        <entry>$500</entry>
                        <entry>$550</entry>
                        <entry>$480</entry>
                    </row>
                    <!-- More rows... -->
                </tbody>
            </tgroup>
        </table>