Version 1.0
Last Revised: June 14, 2002
This section of the guidelines will explain the elements used to mark up tables. The discussion focuses on the markup of straightforward tables. For information on tagging more complex tabular material, see the "Tables" section of the DTBook DTD, the XHMTL1.1 specification, from which the table model is drawn, or applicable reference works.
Definition: A table is an arrangement of data with two or more columns and one or more rows in which the information in the leftmost column relates specifically to the information in the other column or columns. The format of a table may vary depending on the project style. A table usually has column headings and may or may not have a title.
Tables normally read across from left to right, that is, information in the right columns relates horizontally to the information in the left columns.
Markup: Tables are marked up using the <table> element in combination with the <caption>, <thead> (header), <tbody> (main body of table), <tr> (table row), <th> (cell containing header information), and <td> (cell containing table data) elements. The <tfoot> tag can be used to add footer information. In addition, <col> defines the alignment properties for cells in one or more columns and <colgroup> groups adjacent columns that are semantically related.
The <table> tags surround the entire table. Certain optional elements, if used, must follow in this sequence: <caption>, either <col> or <colgroup>, <thead>, and <tfoot>. Any or all of these elements may be used. The content of the table follows. In simple tables, <tr> marks each row of table data cells (<td>). In tables consisting of multiple sections, <tbody> marks each section and contains one or more rows (<tr>).
The <thead> and <tfoot> elements contain header and footer information, respectively, in rows <tr> of cells (usually <th>). Each, if used, may be used only once, but applies to all sections (<tbody>) of the table. Browsers and playback devices can duplicate headers and footers when breaking a table across page boundaries, or present them statically when
sections are rendered in a scrolling panel.A long table crossing several pages of the print book should have separate <pagenum> values for each of the pages containing that <table> indicated on the page where it starts. A <prodnote> explaining that the table spans several pages should be added.
Element:
<table>...</table> <caption>...</caption> <col>...</col> <colgroup>...</colgroup> <thead>...</thead> <tfoot>...</tfoot> <tbody>...</tbody> <tr>...</tr> <th>...</th> <td>...</td>
Example 1 shows a very simple table with no caption, footer, or <tbody>:
<table border="1">
<thead>
<th>Parent Company</th>
<th>Divested Business</th>
</thead>
<tr>
<td>U.S. Sprint</td>
<td>Cellular phone</td>
</tr>
<tr>
<td>Union Pacific</td>
<td>Oil, gas</td>
</tr>
<tr>
<td>Viacom</td>
<td>Cable TV</td>
</tr>
</table>
This table would be rendered as:
Parent Company Divested Business U.S. Sprint Cellular phone Union Pacific Oil, gas Viacom Cable TV
Example 2:
<table border="1">
<caption>This table contains both a header and a footer.</caption>
<thead>
<tr>
<th>Number</th>
<th>A</th>
<th>B</th>
<th>C</th>
</tr>
</thead>
<tfoot>
<tr>
<td>Footer Number</td>
<td>Footer A</td>
<td>Footer B</td>
<td>Footer C</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>1</td>
<td>A1</td>
<td>B1</td>
<td>C1</td>
</tr>
<tr>
<td>2</td>
<td>A2</td>
<td>B 2</td>
<td>C2</td>
</tr>
<tr>
<td>3</td>
<td>A3</td>
<td>B3</td>
<td>C3</td>
</tr>
</tbody>
</table>
This table would be rendered as:
This table contains both a header and a footer. Number A B C Footer Number Footer A Footer B Footer C 1 A 1 B 1 C 1 2 A 2 B 2 C 2 3 A 3 B 3 C 3
Example 3 shows how to start a table that spans three pages:
<pagenum id="pg255" page="normal">255</pagenum>
<pagenum id="pg256" page="normal">256</pagenum>
<pagenum id="pg257" page="normal">257</pagenum>
<prodnote render="optional">The following table spans pages 255 to 257.</prodnote>
<table>
. . .
Copyright © 2002 DAISY Consortium