The Parts of a Data Table

The best understanding of data table markup begins with an examination of the smaller parts of a table, as illustrated in Figure 10-1.

Data table anatomy

Figure 10-1. Data table anatomy

Rows and cells: tr and td

These will typically contain all of the data points that relate to a single item. Rows are themselves divided into cells (td), and analogous cells in separate rows are always rendered into consistent columns. Apart from tbody, rows and cells are the two elements that must be present in a table.

Readers who are familiar with relational databases will recognize that tr elements signal the bounds of a single record.

Columns and column groups: col and colgroup

Just as a row relates to a single item, a column relates to a common class of data. Each column in a table corresponds to the table cells found at an interval of n, given that n equals the number of cells in each row.

Row and column headings: th

th functions as an alternative to td, and defines the character of data found in a particular row or column.

th elements are distinct from td elements not only in terms of presentation, but also because they are set aside specifically to create table cells that do not contain actual data.

Captions: caption

Headings are assigned to normal copy; in spite of their name, captions serve an analogous role for data tables. They are always rendered at the top of tables, as a heading would ...

Get HTML & CSS: The Good Parts now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.