We have been studying the DocBook DTD and in particular the table specifications. There are two separate and distinct formats supported, the originals CALS format and the ‘newer’ HTML format since DocBook version 4.3. CALS is an SGML standard developed by the U.S. military, and their set of table tags was one of the first to be developed that included complex features for tables.
Some confusion was encountered since one source claimed that both table formats could not be used in the same document, whilst another source claimed that the two forms cannot be mixed within the same definition, which makes more sense.
Later, because of widespread familiarity with HTML tables, DocBook added HTML table elements. Now you can use tr
and td
instead of row
and entry
in a table. They cannot be mixed within one table. Also, the content of each table cell has to be valid DocBook, so you cannot usually just cut and paste an HTML table into your DocBook document. But the DTD does permit a document to contain both CALS tables and HTML tables. The tgroup
element is the distinguishing characteristic between them. A CALS table requires a tgroup
, and an HTML table does not permit one.
The formats are sufficiently similar that it is worth mentioning them here. The following table neatly summarises the differences.
Purpose | HTML Element | CALS Element | Comments |
Container for table elements. | table , informaltable |
table , informaltable |
The CALS table element requires a title , an HTML table element requires a caption . An informaltable accepts neither. |
Table title | caption |
title |
Use informaltable for an HTML table without a caption. |
Wrapper for table section | Not available | tgroup |
HTML tables do not support subsections of a table with different column specifications. CALS requires at least one tgroup . |
Column specifications | col , colgroup |
colspec , spanspec |
The CALS spanspec element specifies horizontal spanning (joining) of cells. |
Wrapper for header rows | thead |
thead |
|
Wrapper for body rows | tbody |
tbody |
|
Wrapper for footer rows | tf |
tf |
In both HTML and CALS, tfoot must appear before tbody . |
Row | tr |
row |
All open tr tags must have a closing tag. |
Cell | td , th |
entry |
All open td tags must have a closing tag. |
Nested table | informaltable inside a td |
entrytbl inside a row |
Nested HTML tables permitted since version 4.4 of the DTD. |
The table format is not what I would call very pretty and we are investigating how one can use different CSS classes to make them ‘prettier’.