Sub topic 2
Anatomy of a Comparison Table
Assume you know basic HTML and CSS, understand responsive layout, and have seen SaaS subscription pricing. A comparison table should answer one question quickly: which plan matches this visitor’s needs?
Table structure
Put plans in columns and comparison criteria in rows. Keep each row focused on one customer question. Group related rows under labels such as Collaboration, Security, and Limits.
| Element | Purpose |
|---|---|
| Plan header | Names the available choice |
| Feature row | Compares one capability or limit |
| Call to action | Gives the visitor a clear next step |
| Supporting note | Explains billing, limits, or exceptions |
Hierarchy, highlighting, and calls to action
Use visual hierarchy to make scanning easy. Give plan names and prices the strongest emphasis, then group labels, feature names, and details in descending order.
Highlight a recommended plan only when it reflects evidence, such as the plan most customers choose or the plan that fits the stated audience. Label the reason clearly. Do not hide alternatives or make the recommended plan appear selected by default without explanation.
Use one primary call to action per plan, such as “Start free trial” or “Contact sales.” State important conditions near it, including trial length, taxes, or whether a credit card is required.
> callout note > A checkmark alone is ambiguous. Use text such as “Included,” “Up to 10 users,” or “Available on request” when the distinction affects a buying decision. > ```
Monthly and annual billing toggles
A billing toggle must update every affected price, billing suffix, and savings claim together. Store both values in one data structure rather than calculating them independently in different components. Use aria-pressed so assistive technology can detect the current state.
const toggle = document.querySelector("#billing-toggle");
toggle.addEventListener("click", () => {
const annual = toggle.getAttribute("aria-pressed") !== "true";
toggle.setAttribute("aria-pressed", String(annual));
document.querySelectorAll("[data-monthly][data-annual]").forEach((el) => {
el.textContent = annual ? el.dataset.annual : el.dataset.monthly;
});
});Building the table with semantic HTML
Use a real table element for two-dimensional comparisons. Add a caption, identify column headers with scope="col", and identify feature labels with scope="row". Decorative symbols need text alternatives.
<table>
<caption>Compare plans</caption>
<thead>
<tr>
<th scope="col">Feature</th>
<th scope="col">Starter</th>
<th scope="col">Team</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Projects</th>
<td>3</td>
<td>Unlimited</td>
</tr>
<tr>
<th scope="row">Single sign-on</th>
<td><span aria-label="Not included">No</span></td>
<td><span aria-label="Included">Yes</span></td>
</tr>
</tbody>
</table>Exercise
Why should a feature label use a row header instead of an ordinary table cell?
Show answer
A row header identifies the meaning of the values in that row, which helps people and assistive technology interpret the comparison.