Sub topic 6
Anatomy of a comparison table
This chapter assumes you know basic HTML tables and CSS, and that you have read the earlier chapters on tiers and feature selection. Here you will learn what parts a plan comparison table has and what each part does for the visitor.
The four parts
A comparison table answers one question: "Which plan gives me what I need?" Each part of the table serves that question.
- Plan header row. One column per plan, with the plan name. In later chapters you will add price and a call to action here.
- Feature column. One row per feature, labelled on the left. Visitors read down this column to find what they care about.
- Cells. The value of one feature in one plan: a number, a word, or an included/not-included mark.
- Caption. A short title for the table, such as "Compare plans".
Plans as columns, features as rows
Put plans in columns and features in rows. Plan lists are short, usually three or four, so they fit across the screen. Feature lists grow, and a page scrolls down easily. Visitors compare one feature across plans by reading along a row. They judge one plan as a whole by reading down a column.
Group related rows under short section headings, such as "Collaboration" or "Security". Use the grouping you chose in the previous chapter. Keep the order stable within each group.
Writing cell values
Make every cell in a row the same kind of value. Do not mix "Unlimited", "Yes", and "10 GB" in a single row, because the visitor cannot tell which is better.
| Feature type | Cell value | Example |
|---|---|---|
| Quantity | A number or "Unlimited" | 3, Unlimited |
| Yes/no | A mark with a text alternative | Included, Not included |
| Level | A short word | Basic, Priority |
Do not leave a cell blank. A blank cell could mean "not included", "unknown", or "forgot to fill in".
A minimal accessible table
The markup below shows all four parts. The first header cell is empty visually, so it carries hidden text. The check and cross symbols are hidden from screen readers with aria-hidden, and a hidden text label says the same thing in words.
<table class="plans">
<caption>Compare plans</caption>
<thead>
<tr>
<th scope="col"><span class="visually-hidden">Feature</span></th>
<th scope="col">Starter</th>
<th scope="col">Team</th>
<th scope="col">Business</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Projects</th>
<td>3</td>
<td>Unlimited</td>
<td>Unlimited</td>
</tr>
<tr>
<th scope="row">Single sign-on</th>
<td><span aria-hidden="true">✕</span><span class="visually-hidden">Not included</span></td>
<td><span aria-hidden="true">✕</span><span class="visually-hidden">Not included</span></td>
<td><span aria-hidden="true">✓</span><span class="visually-hidden">Included</span></td>
</tr>
</tbody>
</table>The visually-hidden class is defined in the responsive-tables chapter. Until you add it, the hidden text will show on screen.
Common errors
- Using
<td>for labels. Feature names should be<th scope="row">. Otherwise a screen reader cannot tell the visitor which feature a cell belongs to. - Symbols with no text. A bare checkmark is read as nothing, or as an unhelpful character name.
- Too many rows. If the table needs more than about 15 to 20 rows, move detail to a separate page and keep only the deciding features here.
- Leaving out the caption. Without it, a screen reader user who jumps to the table has no title for it.
Exercise
A table cell for "Priority support" on the Starter plan contains only an empty <td>. Name two problems with this and say what to put there instead.
Show answer
A visitor cannot tell whether the feature is excluded, unknown, or forgotten, and a screen reader announces nothing useful. Put a mark with a text alternative, such as a cross with hidden text "Not included", or a word such as "Email only" if the support level differs.