Tables

Tables provide grid-formatting of related data, where eeach row is an item, and each column provides information about the item.

Use table elements and class formatting to define how tables look when published.

Table with heading row

Headings identify the data in the column. Headings are optional; included them as needed.

NamesValues
a123
b687
c488

No heading row

Omit heading when the table contents is obvious based on the surround context.

a123
b687
c488

Table with a title

Only include a title when necessary for referencing the table in text. And then it is best to include a link to the table, like for This is a table title.

Table 1. This is a table title
NameValue
MikeAwesome
OtherOK

Table full-width, unequal column widths

Create a table that fills the 100% the width of the content column by assigning table-full-width to the outputclass attribute for the <table> element.

Important: Verify the output before publishing using this option. When a table cell contains a LOT of text, the resulting table is too wide to fit in the page-column and is messes up other tables on the page.
NamesDescription
aSome reasonable textual description.
b687
c488

Table with equal-width columns

Create equal-width columns by assigning table-equal-cols to the outputclass attribute for the <table> element.

Important: Verify the output before publishing using this option. When a table cell contains a LOT of text, the resulting table is too wide to fit in the page-column and is messes up other tables on the page.
NameValue
MikeAwesome
OtherOK

Column width specifications

Be default, browsers apply their own algorithms to evaluate table content, and then attempt to automatically size the columns appropriately. You can provide guidance or specificity to the browser using DITA column-width specifiers.

For example, consider this table:

AlphaBetaDelta
This and the next column are the same width.This and the previous column are the same width.This column is twice a wide as each of the previous two columns.

The widths are assigned to each colum as a proportion of the entire table width using the colwidth attribute in the table source code. This specification says the table width can be dived into 4 equal portions (1+1+2), and the first two columns each get one portion (1*) while the third column gets two portions (2*).

…
   <tgroup cols="3">
      <colspec colname="c1" colnum="1" colwidth="1*"/>
      <colspec colname="c2" colnum="2" colwidth="1*"/>
      <colspec colname="c3" colnum="3" colwidth="2*"/>
      <thead>
         …

When using proporttionals widths, assign the attribute to all columns or you will get undesirable results.

AlphaBetaDelta
This column has no sizing.This column has no sizing but it has more text, which usually forces the browser to allocate more width to it.This column is assigned one proportion of the table's width.

The colwidth specifcation looks like this:

…
   <tgroup cols="3">
      <colspec colname="c1" colnum="1" />
      <colspec colname="c2" colnum="2" />
      <colspec colname="c3" colnum="3" colwidth="1*"/>
      <thead>
         …

The colwidth attribute can also accept fixed units (like inches, points, and pixels), which should be avoided except in the most extreme cases. When you do use it, use "rem" units, which are equal to the with of the capital letter 'M' in the base font for the page.

AlphaBetaDelta
This column width is "15rem".This column has no sizing. This column has no sizing. It does, however, have a lot of text which should force the browser to allocaet space for it.

The colwidth specifcation looks like this:

…
   <tgroup cols="3">
      <colspec colname="c1" colnum="1" colwidth="15rem"/>
      <colspec colname="c2" colnum="2" />
      <colspec colname="c3" colnum="3"/>
      <thead>
         …

"Double-entry" table

A "double-entry" table has heading across the top and down the first (left) column.

Assign th to the outputclass attribute for an <entry> cell, you can make it look like a heading.

Skill 1Skill 2
Member 1X
Member 2X
Member 3XX

Simple Table

DITA has an element called a Simple Table (<simpletable>).

Restriction: Never, nevenr, never use the DITA Simple Table type. It causes too many problems.

Wide table with horizontal scroll

The <table> is in a <p outputclass='table-h-scroll>, like this:

<p outputclass="table-h-scroll">
    <table>
         ...               
                
FunctionDescriptionParametersOutput data typeSyntaxExample
DATEReturns a date value from year, month, and day values you enter.Year (YYYY), Month (MM), Day (DD)DateDATE(year, month, day)DATE("2020", "01", "01")
DATEDIFCalculates the number of days, months, or years between two dates.Date, Date, TypeIntegerDATEDIF(date, date, type)DATEDIF([Creation date] , [Response date], "D")
getUnitGroupDatafieldRetrieves a Unit group Data field value by descending through the levels of Unit group children from the starting node. Descending will stop once there are no more children or the maxDescendantLevel has been reached. If the given Unit belongs to more than one leaf unit group at the final level, an exception will be thrown because we cannot be sure which is the desired value. If there is more than one leaf, then the setup will need to change. Returns a string value of the one Unit Group Data field found or null if not.getUnitGroupDatafield(unit, text, integer, text)getUnitGroupDatafield([Account], 'b2b_region', 1, 'name')