What are table headers and footers in DITA tables?
In DITA, headers and footers in tables are special rows that provide additional information or context for the data in the table. Headers typically appear at the beginning of the table and contain titles or descriptions for each column, while footers appear at the end of the table and can contain summary information or notes related to the table’s content. These elements enhance the readability and understanding of tabular data in DITA documents.
Table Headers:
Table headers are rows at the top of a table that serve to label or describe the data in each column. They provide context and help readers understand the content of the columns. Headers are typically used to label columns in a table. Each cell in the header row corresponds to a specific column in the table’s body. In DITA, headers are often visually distinguished from the table’s body, such as by using bold text or a different background color.
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>
Table Footers:
Table footers are rows at the bottom of a table that can contain summary information or notes about the data in the table. They provide additional context or explanation. Footers are used to summarize or add notes to the table’s content. They may not be present in all tables and are typically used when additional context is needed. Similar to headers, footers can be visually distinguished from the table’s body to make them stand out.
Example:
<table>
<title>Monthly Sales Report</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>Product</entry>
<entry>Units Sold</entry>
<entry>Revenue</entry>
</row>
</thead>
<!-- Table body rows -->
<tbody>
<row>
<entry>Product A</entry>
<entry>100</entry>
<entry>$1,000</entry>
</row>
<!-- More rows... -->
</tbody>
<!-- Table footer row with summary -->
<tfoot>
<row>
<entry>Total</entry>
<entry>500</entry>
<entry>$5,000</entry>
</row>
</tfoot>
</tgroup>
</table>
In this example, the <thead> element defines the table header row, while the <tfoot> element defines the table footer row with a summary of the data.