Lists are good for reading items one at a time. When every item has the same kinds of information, such as a time and topic, rows and columns make comparison easier. Use an HTML table for this tabular data.
Rows contain cells
table wraps the table, tr is a table row, th is a header cell and td is a data cell:
<table>
<caption>Saturday schedule</caption>
<thead>
<tr><th scope="col">Time</th><th scope="col">Topic</th></tr>
</thead>
<tbody>
<tr><td>10:00</td><td>Free reading</td></tr>
<tr><td>14:00</td><td>Discussion</td></tr>
</tbody>
</table>Place cells in the same column order in every row. thead groups header rows, tbody groups data rows and caption names the whole table. Write caption once at the beginning of table.
Headers convey relationships
th is a header, not just bold text. scope="col" associates it with its column. A header naming a data row can use scope="row". These relationships help assistive technology describe data. Adding strong inside td does not give that cell header semantics.
Spanning cells
colspan="2" makes one cell occupy two columns; rowspan="2" makes it occupy two rows. Recheck the occupied grid positions after merging cells to avoid misalignment. Begin with simple tables and merge only when the data calls for it.
The second Lab example adds tfoot, a group for summary rows, with a note spanning two columns. A native table may have no visible grid borders; that does not mean it failed to render. CSS will later add borders and spacing. Use tables for data, not to lay out an entire page in columns.
Page experiment: Tables
Compare the examples, then change one part of the HTML using the observation prompt. Compare the source with the real rendered page.
Read down each column: times and topics stay aligned. No extra borders have been styled.
The preview uses native browser headings, paragraphs and form controls. Switching examples replaces your edits; Reset lab restores the initial state. Follow in-page links, type and select options. This practice preview does not send form data or run scripts. To try locally, save the complete code as index.html and open it in a browser.
KNOWLEDGE QUIZ
Build it yourself: Tables
Create index.html, write a complete page using the requirements below, then save and open it in a browser. Interact with the page to check it. The reference is one possible implementation; wording may differ.
- Make a three-column table for Time, Activity and Place, with a caption, headers and two data rows.
- Set scope on column headers and check that each row has three cells in the same order.