How are titles and captions added to DITA tables?

Titles and captions can be added to tables to provide context and labeling. These provide readers with information about the table’s content, purpose, or context.

The title is typically placed above the table and provides a brief description or title for the entire table. This title helps readers understand the content of the table before diving into the details. The caption appears below the table and is used to provide additional information or context for the table. Captions can be longer than titles and often offer more detailed explanations. Titles and captions in DITA tables are usually placed within <title> and <caption> elements, respectively. These elements are commonly placed within the <table> element but can also be part of individual table column or row groups.

Example:


        <table>
          <title>Product Comparison</title>
          <caption>A comparison of features in different product versions.</caption>
          <tgroup cols="3">
            <colspec colname="col1" colwidth="1*"/>
            <colspec colname="col2" colwidth="1*"/>
            <colspec colname="col3" colwidth="1*"/>
            <tbody>
              <row>
                <entry>Product</entry>
                <entry>Version 1</entry>
                <entry>Version 2</entry>
              </row>
              <row>
                <entry>Feature 1</entry>
                <entry>Yes</entry>
                <entry>No</entry>
              </row>
              <row>
                <entry>Feature 2</entry>
                <entry>Yes</entry>
                <entry>Yes</entry>
              </row>
            </tbody>
          </tgroup>
        </table>
    

In this example, the <title> element provides a brief title for the table, indicating it’s a “Product Comparison.” The <caption> element gives additional context by explaining what the comparison is about. These elements help readers understand the purpose of the table and the information it presents.