Chapter 3.8. Tables

Following table lists all supported elements and attributes for defining tables. Only the listed elements and attributes are supported for interactive and print output. The meaning of the elements and attributes is as defined by the XHTML standard.
ElementSupported
attributes
Comment
table
align, bgcolor, border, cellpadding, cellspacing, class, frame, id, rules, title
A new table.
caption
 
The title line of the table.
thead
 
The table header.
tfoot  
The table footer.
tbody  
The table body.
tr
align, bgcolor, class, style, valign
A table row.
th
align, bgcolor, class, colspan, height, nowrap, rowspan, style, valign, width
A header cell.
td
align, bgcolor, class, colspan, height, nowrap, rowspan, style, valign, width
A table cell.
colgroup   A group of column definitions.
col width A column definition.
Specifying the table width
To define the width of a table, either the width or the style attribute can be used. For example, following two elements both define a table with a width of 250 pixels:
<table width="250"> ... </table>
<table style="width:250px"> ... </table>
Instead of setting a fixed with, the width can also be specified in percent. A percent value defines the width relative to the screen or page width. Example:
<table width="80%"> ... </table>
Specifying the column widths
To define the width of a column, either a colgroup element has to be provided or the width of a td/th element needs to be set. Following two examples both define a table with the same column widths:
<table>
  <colgroup>
    <col width="80" />
    <col width="70" />
    <col width="100" />
  </colgroup>
  <tr>
    <td>1. Row, 1. Column</td>
    <td>1. Row, 2. Column</td>
    <td>1. Row, 3. Column</td>
  </tr>
  ...
</table>
This is equivalent to:
<table>
  <tr>
    <td width="80">1. Row, 1. Column</td>
    <td width="70">1. Row, 2. Column</td>
    <td width="100">1. Row, 3. Column</td>
  </tr>
  ...
</table>
If the column width is specified in the td/th element, then it is sufficient to set the width for only one cell per column (for example the cells in the first row).
The width of cells can also be specified in percent. A percent value defines the width relative to the complete width of the table.
Cell formatting
By default, the block-style with ID "table_cell" is applied to table cells that are defined by the td element. The block-style with ID "table_header" is applied to table cells that are defined by the th element. However, any other user-defined block-style can be applied to a cell by supplying the class attribute.
Even though it is possible to specify the background-color of a table / row / cell through the bgcolor attribute, it is recommended to define the background-color by assigning a block-style through the class attribute (the background-color can then be set as CSS property background-color).
Referencing tables
Tables can be referenced as described in Section 3.4.2, “Referencing Figures, Tables and other Content”. Be aware that for tables the caption element has to be used to define the table title (instead of the title attribute).
Page breaks within tables
By default, no page breaks are inserted within a table. If the remaining space on a page is less than the height of the table to be inserted, then the formatter automatically inserts space in front of the table, so that the table starts at the beginning of the next page. This bevaviour makes sense for small tables. However, if a table is large then a lot of space may appear in front of the table. Furthermore, if a table is larger than the height of a page, then the table is cut off at the bottom of the page. To avoid this, the formatter can be instructed to allow page-breaks within a table, by assigning the CSS class keep_together_auto:
<table class="keep_together_auto"></table>
Defining landscape tables
A landscape table can be defined by setting the class attribute to the value "landscape_table":
<table class="landscape_table"></table>