Sub topic 11
Accessible pricing tables
This chapter assumes you can write basic HTML and CSS and that you have read the chapters on table anatomy, semantic markup, and responsive tables. Here you will check a comparison table against what screen reader users, keyboard users, and low-vision users need.
Why pricing tables fail
A pricing table is a data table. Visitors compare plans across features, so the structure has to carry that grid to people who cannot see it. Four problems come up most often:
- Headers are not tied to cells, so a screen reader reads "Unlimited" with no plan or feature name.
- Check and cross icons have no text, so the cell reads as empty.
- The scroll wrapper cannot be reached by keyboard.
- Color alone marks the recommended plan, or text contrast is too low.
Associate headers with cells
Use th for every header and set scope="col" for plan names and scope="row" for feature names. A screen reader can then announce "Team, Projects, Unlimited" as the user moves between cells. Add a caption so the table has a name in the list of landmarks and tables on the page.
Keep the top-left cell as a th, and give it hidden text such as "Feature" instead of leaving it empty. An empty header cell is often announced as "blank".
Give symbols a text alternative
Screen readers may skip a decorative symbol or read it as "multiplication x". Hide the symbol from assistive technology and add real text in a visually hidden element:
<td>
<span aria-hidden="true">✓</span>
<span class="visually-hidden">Included</span>
</td>Use the same words every time, such as "Included" and "Not included". Partial support needs words too, for example "Up to 5 users". A bare dash is ambiguous.
Make the scroll area keyboard-reachable
A wrapper with overflow-x: auto scrolls with a mouse or touch. Keyboard users need to focus it first. Make the wrapper focusable, give it a role and a name, and show a visible focus ring:
<div class="table-wrap" tabindex="0" role="region" aria-labelledby="plans-caption">
<table class="plans">
<caption id="plans-caption">Compare plans</caption>
<!-- table content -->
</table>
</div>.table-wrap:focus-visible {
outline: 3px solid #1a56db;
outline-offset: 2px;
}Sticky headers and row labels help sighted users keep their place. They do not change the reading order, so the markup stays correct.
Do not rely on color
Highlight the recommended plan with text such as a "Recommended" label in the column header, not only a colored background. Give that label a text alternative of its own if it is an icon. Check these values:
| Element | Minimum contrast |
|---|---|
| Body and price text | 4.5:1 against its background |
| Large text (about 24px, or 19px bold) | 3:1 |
| Focus ring and icon borders | 3:1 against neighbors |
Test the highlighted column too, since a tinted background can lower the contrast of text that passed on white.
Keep controls accessible
The billing toggle should be a real button with aria-pressed, as shown in the toggle chapter. When the price text changes, the new price is not announced by default. Add a polite live region for a short message such as "Showing annual prices", and do not put the whole table in it.
Call-to-action links need unique names. Eight links reading "Choose plan" are hard to tell apart in a list of links. Add hidden text or aria-label, such as "Choose Team plan", and make sure the visible text is part of the accessible name.
Test it
- Tab through the page. Every control and the scroll area must receive a visible focus ring, in a logical order.
- Turn on a screen reader and move through cells with its table commands. Each cell should announce its plan and feature.
- Zoom to 200% and confirm the content still works.
- Run an automated checker, then treat it as a first pass. It cannot judge whether the announced text makes sense.
Exercise
A table cell shows only a green check icon, and a screen reader user hears nothing for it. Which fix is correct: adding display: none text reading "Included", or adding a visually-hidden span reading "Included" and marking the icon aria-hidden="true"?
Show answer
Use the visually-hidden span and mark the icon aria-hidden="true". display: none removes the text from the accessibility tree, so the screen reader still hears nothing. A visually-hidden class hides the text only from sight.
Exercise
Name two reasons a plan table with a scrolling wrapper can still fail a keyboard user, and give a fix for each.
Show answer
The wrapper may not be focusable, so the user cannot scroll it. Fix this with tabindex="0", a role, and an accessible name. The focus ring may also be invisible. Fix this with a :focus-visible outline that has at least 3:1 contrast.