Show All Hide All Printer Friendly Version Web Friendly Version

DAISY Consortium Logo - Link to Home PagePart II(d): Tables

DAISY 3 Structure Guidelines
Last Revised: June 4, 2008

This section of the guidelines explain the elements used to mark up 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.

Information Object: Tables

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.

Bibliographic Reference

Markup

Tables are marked up using the <table> element in combination with the <caption>, <thead> (header), optional <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, in the tbody element, follows. In simple tables, <tr>s mark 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 table header and footer information, respectively, in rows <tr> of cells (usually <th> which distinguishes table information from table data). Each, if used, may be used only once, and applies to all <tbody>s of the table. For a multiple-page print table, the browser or playback device may choose to repeat <thead> and <tfoot> on each page; therefore, they should not be redundantly tagged.

Note that the content model of the table element used in DTBook differs from the content model described in XHTML 1.1

A long table spanning several pages of the print book should have separate <pagenum> values for each of the pages on which the table appears. A <prodnote> explaining that the table spans several pages should be added prior to the table.

New in DTBook-2005-3: <pagenum>s may now be included within <table>, before or after <tr> elements.

Syntax


<table>

  <caption>...</caption>

  <col>...</col>

  <colgroup>...</colgroup>

  <thead>...</thead>

  <tfoot>...</tfoot>

  <tbody>...</tbody>

  <tr>

    <th>...</th>

    <td>...</td>

  </tr>

  <pagenum>...</pagenum>

</table>

Examples

Example 1

This is a very simple table with no caption, footer, or <tbody>:


<table border="1">

  <thead>

    <tr>

      <th>Parent Company</th>

      <th>Divested Business</th>

    </tr>

  </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>

      <th>Footer Number</th>

      <th>Footer A</th>

      <th>Footer B</th>

      <th>Footer C</th>

    </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>B2</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

This example shows how a table that spans three pages can be set up. Page numbers appear between table rows.


<pagenum id="pg255" page="normal">255</pagenum>

<prodnote render="required">The following table spans pages 255 to 257. Text.</prodnote>



<table>

    <caption>This table contains a header.</caption>

    <thead>

        <tr> <th><!-- ... --></th> </tr>         

    </thead>

    <tbody>

        <tr> <td><!-- ... --></td> </tr>

        <tr> <td><!-- ... --></td> </tr>        

        <pagenum id="pg256" page="normal">256</pagenum>

        <tr> <td><!-- ... --></td> </tr>

        <tr> <td><!-- ... --></td> </tr>       

        <pagenum id="pg257" page="normal">257</pagenum>

        <tr> <td><!-- ... --></td> </tr>

        <tr> <td><!-- ... --></td> </tr>       

    </tbody>

</table>





Illustrated Example 1

Page Sample:

(Show/Hide)

Sample Code:

(Show/Hide)

Comments and Alternative NIMAS Examples:

(Show/Hide)

Illustrated Example 2

Page Sample:

(Show/Hide)

Sample Code:

(Show/Hide)

Comments and Alternative NIMAS Examples:

(Show/Hide)