smartyfy.mrindigi.com

Web Development Pro | Lesson 006 | Lists and Accessible Data Tables

Web Development Pro · Lesson 06 of 60

Module 1: HTML foundations

In this lesson

Prerequisites and learning outcomes

Complete lesson 5 first. This lesson builds on structured lists and tabular relationships. By the end, you can use real lists and table headers to represent a workshop schedule. Plan 10–15 minutes for the core explanation and additional time for the worked practice.

Match structure to the information

The workshop has three things to bring, four preparation steps, and a schedule comparing sessions by time and room. These are different relationships. An unordered list groups items whose sequence is not important. An ordered list expresses a sequence or ranking. A table connects values across rows and columns. Choosing the right structure helps readers understand what belongs together without guessing from spacing.

Do not simulate bullets with asterisks typed into paragraphs, or align a schedule using repeated spaces. Browsers collapse many whitespace sequences, and proportional fonts have letters of different widths. More importantly, visual alignment alone does not tell assistive technology that a time belongs to a particular session. HTML can represent those relationships directly.

Use lists for collections and sequences

A ul or ol contains li elements. A nested list belongs inside the li that introduces it, not as a sibling between list items. Use ul for items such as a notebook, a reusable bottle, and the object to repair. Use ol when changing the order would change the process, such as check in, meet the facilitator, then begin the activity.

<h2>Before the workshop</h2>
<ol>
  <li>Choose a session.</li>
  <li>Read its preparation notes.</li>
  <li>Gather the suggested tools.
    <ul><li>A notebook</li><li>A reusable bottle</li></ul>
  </li>
</ol>

A description list, using dl with dt and dd, suits name-value or term-description relationships. It can explain “Facilitator” and “Participant,” or present simple event facts. It is not a substitute for every two-column layout. Choose it because each term is associated with a description, then let CSS decide how that association appears.

Build a small data table

Start with the question the table answers: which session meets at each time and room? Each body row represents one session. Each column represents one attribute. A caption names the table's purpose. Column headers use th with scope="col". If the first cell names the session for its whole row, make it a row header with scope="row".

<table>
  <caption>Saturday workshop schedule</caption>
  <thead>
    <tr><th scope="col">Session</th><th scope="col">Time</th><th scope="col">Room</th></tr>
  </thead>
  <tbody>
    <tr><th scope="row">Bicycle basics</th><td>10:00</td><td>River room</td></tr>
    <tr><th scope="row">Mending clothes</th><td>11:30</td><td>Garden room</td></tr>
  </tbody>
</table>

Thead groups the header rows and tbody groups the body rows. They do not replace individual header cells. A td made bold with CSS still lacks th semantics. Similarly, putting the word “Schedule” in a paragraph nearby is not identical to supplying a table caption, which is programmatically associated with the table.

Keep relationships simple

Merged cells using rowspan or colspan can represent complex headings, but they also make authoring and navigation more demanding. Before adding them, ask whether two simpler tables would communicate the data more clearly. This example needs neither. A plain rectangular table with clear headers is a strong starting point for both accessibility and maintenance.

Do not use tables to position the site header beside a sidebar. A layout grid and a data table solve different problems. Tables are appropriate when understanding a cell requires its row and column relationships. A set of workshop cards is not automatically tabular simply because you want three cards across a screen.

For missing information, write an honest value such as “Room not yet assigned” when that distinction matters. A blank cell could mean unknown, unavailable, or accidentally omitted. Do not use a dash without explaining it when multiple interpretations are possible. In a real schedule, include the date and relevant timezone or local-time context so a bare 10:00 is not misleading.

Review content before styling

Read each row aloud with its headers: Bicycle basics, time 10:00, room River room. If this sounds repetitive but understandable, the relationship is probably clear. Then verify that every row has the expected cells and that the header wording matches the values. A column titled “Duration” should not contain start times.

On a narrow screen a large table may require careful handling, such as a labeled horizontally scrollable region. That CSS work comes later. Do not delete meaningful columns solely to make the current page look tidy. First identify what information users need, then choose a presentation that preserves it. Back up your practice folder before experimenting with the table structure.

Worked practice

Worked exercise 1: Choose the right list

Task: Mark up “Check in, collect a repair kit, meet the facilitator.” Worked answer: use ol because these are successive steps. Each step is an li. If “notebook, bottle, gloves” are simply items to pack, use ul instead because their order does not affect the task.

Worked exercise 2: Repair a false header

Task: The first schedule row uses td cells with bold text. Worked answer: replace those cells with th scope="col" and group them in thead. Keep the session-name cells in the body as th scope="row". Visual boldness alone does not expose header relationships.

Worked exercise 3: Interpret a missing room

Task: Mending clothes has no confirmed room. Worked answer: put “Room not yet assigned” in its room cell. This explicitly distinguishes an unconfirmed value from a formatting gap. When a room is confirmed, update that cell rather than adding a disconnected note elsewhere on the page.

Knowledge check

Question 1

Which list represents a meaningful sequence? A) ol. B) ul. C) dl. D) A paragraph with line breaks.

Check question 1: answer and explanation

Answer: A. Ordered lists communicate ordering rather than a simple collection.

Question 2

Where does a nested list belong? A) Inside the relevant li. B) Between li elements as their sibling. C) Inside the parent list before its first li. D) In a separate unrelated list after the parent.

Check question 2: answer and explanation

Answer: A. Nesting within the parent item preserves the relationship.

Question 3

What names a table programmatically? A) A paragraph above it without association. B) caption. C) A bold first data cell. D) A heading inside the first td.

Check question 3: answer and explanation

Answer: B. Caption is associated with its table and explains its subject.

Question 4

What does scope="row" indicate on th? A) A cell spanning every row. B) A header for the entire table. C) A header for its row. D) A row whose cells are all headers.

Check question 4: answer and explanation

Answer: C. It clarifies the row relationship for the header cell.

Question 5

When should you use a table? A) Whenever two things sit side by side. B) To align every page. C) Only for numbers. D) When row-column relationships convey data.

Check question 5: answer and explanation

Answer: D. Tabular meaning, rather than a visual arrangement alone, justifies a table.

Sources and further reading