<colspec>: How do you specify the characteristics of table columns in DITA using the <colspec> element?

Specifying the characteristics of table columns in DITA XML is achieved using the <colspec> element, which allows you to define various properties and attributes for each column within a DITA table. The <colspec> element plays a crucial role in controlling the appearance and behavior of individual table columns.

Column Width

One of the key attributes that can be defined for a table column using the <colspec> element is the colwidth. This attribute specifies the width of the column and can be set to various values, such as a specific measurement (e.g., “1in” for one inch) or a proportional value (e.g., “1*”) to distribute available space proportionally among columns. This flexibility allows you to create tables with columns of different widths based on your content requirements.

Column Alignment

The <colspec> element also allows you to define the alignment of the content within a column using the align attribute. You can set this attribute to values like “left,” “right,” “center,” or “justify” to control how the content in that column is aligned horizontally. This enables you to fine-tune the presentation of data within your tables for better readability and aesthetics.

Column Name

Additionally, the <colspec> element includes the colname attribute, which allows you to assign a name to the column. This name can be used as a reference when styling or scripting the table or for other purposes in your DITA content processing. It provides a way to uniquely identify and work with specific columns within your tables.


Here’s an example of how the <colspec> element is used to specify the characteristics of table columns in DITA XML:

<table id="sample_table">
  <tgroup cols="3">
    <colspec colname="col1" colwidth="1*"/>
    <colspec colname="col2" colwidth="2in" align="center"/>
    <colspec colname="col3" colwidth="1.5in" align="right"/>
        <entry>Data 1</entry>
        <entry>Data 2</entry>
        <entry>Data 3</entry>
        <entry>Data 4</entry>
        <entry>Data 5</entry>
        <entry>Data 6</entry>

In this example, the <colspec> elements are used to define the characteristics of three table columns, specifying their widths, alignments, and names. These attributes control how the content is displayed within each column of the table.