Sub topic 11
Accessible pricing tables
This chapter assumes you can write basic HTML and CSS and that you have built a simple table before. It also assumes you know what a plan comparison table is for. The previous chapters covered the table's structure and the semantic markup. This chapter covers what a person using a screen reader, a keyboard, or a magnifier needs from that table, and the errors that most often break it.
Why pricing tables fail accessibility checks
A pricing table is a data table. It has two dimensions: plans across the top and features down the side. Each cell only makes sense when you know both its plan and its feature. Sighted visitors read that relationship from position. Screen reader users get it from the markup, so the markup has to state it.
Pricing tables tend to fail in five ways:
- The table is built from
divelements, so no row or column relationships exist. - Check and cross icons carry the meaning, and nothing else does.
- The recommended plan is shown only by color or a badge image.
- The table scrolls sideways, but a keyboard user cannot reach the scroll area.
- Focus indicators are removed or hidden behind sticky headers.
Use a real table with explicit header scopes
Use table, caption, thead, tbody, th, and td. Give each header a scope. Plan names are scope="col", and feature names are scope="row". A screen reader can then announce "Business, Single sign-on, Included" when the user lands on a cell.
<div class="table-wrap">
<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>
</div>Three details matter here.
- The caption names the table. Screen readers announce it when the user enters the table, and many offer a list of tables by caption. "Compare plans" is short and specific. A caption can be hidden visually if the design has a heading nearby, but keep it in the DOM.
- The top-left cell is not empty. An empty
this announced as "blank" or skipped, which is confusing. A visually hidden "Feature" label gives the column a name. - Every cell has text. The cell for a missing feature must say something. Never leave it blank.
Give icons a text alternative
Check marks and crosses are symbols. Screen readers may read them as "check mark" or "multiplication x", or skip them. The pattern in the example hides the symbol from assistive technology with aria-hidden="true" and adds real text in a visually hidden element.
The CSS class that does this must hide text visually without removing it from the accessibility tree:
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
border: 0;
}Do not use display: none or visibility: hidden for this. Both remove the text from the accessibility tree, so the screen reader says nothing.
Meaning must not depend on the icon's color either. A green check and a red cross are indistinguishable to many color-blind users. The shapes differ, which helps, but text is still the safest signal. If you want the visible text to carry the meaning too, write "Included" and "Not included" in small type next to the icon on wide screens.
Describe values, not only presence
Not every cell is a yes or no. Cells such as "3", "Unlimited", or "Email only" are already text. Keep them concrete. A cell that says "Limited" gives no useful information to anyone. Say "5 GB" or "10 users". If the cell holds a footnote marker, make it a link or include the note text so the reader can reach it.
Mark the recommended plan in text
Highlighting the recommended plan is a visual-hierarchy choice, covered earlier. Here the rule is that a highlight must also exist in the document. A colored column background or a ribbon that is a background image is invisible to a screen reader.
Add the information as text inside the plan's header cell:
<th scope="col">
Team
<span class="badge">Recommended</span>
</th>If the badge is part of the header, the screen reader announces it with every cell in that column in some reading modes. That can be noisy, so keep the badge to one word. Another option is to place the recommendation in the plan card above the table and leave the table headers as plain names.
Keep the table readable when it scrolls
The responsive chapter used a wrapper with overflow-x: auto so the table scrolls sideways on narrow screens. That works for mouse and touch users. Keyboard users have a problem in some browsers. A scrollable region with no focusable content inside it cannot receive focus, so the arrow keys do nothing.
Modern Chromium and Firefox make scroll containers focusable by default in many cases, but behavior has varied, and Safari has lagged. The safe approach is to make the wrapper focusable and label it:
<div class="table-wrap" role="region" aria-labelledby="plans-caption" tabindex="0">
<table class="plans">
<caption id="plans-caption">Compare plans</caption>
<!-- rows -->
</table>
</div>The role="region" with a name makes the scroll area a landmark that screen readers can announce. The tabindex="0" lets a keyboard user tab to it and scroll with the arrow keys. Give it a visible focus style:
.table-wrap:focus-visible {
outline: 3px solid #1a56db;
outline-offset: 2px;
}If the table has links or buttons in its cells, such as a "Choose plan" button per column, those are focusable already. In that case the wrapper may not need tabindex, but keeping it does little harm. Test in the browsers you support.
Sticky headers and focus
The CSS from the responsive chapter makes the header row and the feature column sticky:
.plans {
border-collapse: separate;
border-spacing: 0;
width: 100%;
min-width: 36rem;
}
.plans thead th {
position: sticky;
top: 0;
background: #fff;
}
.plans tbody th[scope="row"] {
position: sticky;
left: 0;
background: #fff;
text-align: left;
}
.plans th,
.plans td {
padding: 0.75rem 1rem;
border-bottom: 1px solid #ddd;
}Sticky headers help low-vision users who zoom, because the plan names stay in view. They can also cover the element that has focus. When a keyboard user tabs to a button under a sticky header, the browser may scroll it to just behind the header. Add scroll padding so the focused element stays visible:
.table-wrap {
overflow-x: auto;
scroll-padding-top: 4rem;
scroll-padding-left: 10rem;
}This relates to the WCAG 2.2 criterion "Focus Not Obscured (Minimum)". Set the values to match your header height and your feature column width.
Note the background: #fff on sticky cells. Without it, scrolled content shows through the header. With zoom at 200% or 400%, check that a sticky feature column does not take up most of the viewport. If it does, drop the stickiness for narrow widths.
Contrast, zoom, and text size
Pricing pages often use light gray for secondary text, such as "per user per month" or feature descriptions. WCAG asks for a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text and for meaningful graphics such as an icon that carries information. Check these four places in particular:
- Gray helper text under prices.
- Text on the highlighted plan's colored background.
- Disabled-looking cells that show "Not included". They are still content, not disabled controls, and need full contrast.
- Borders and icons that separate or label plans.
Use relative units (rem) for sizes and padding so the table follows the user's font setting. Test at 200% browser zoom and at 400% on a 1280-pixel-wide window, which is equivalent to a 320-pixel viewport. The table should scroll in one direction without hiding content or forcing two-dimensional scrolling for the page as a whole.
Make price changes announce themselves
The billing toggle changes prices on the page. A sighted user sees the numbers change. A screen reader user hears nothing unless you say so. The toggle itself should be a real button with aria-pressed, which reports its state, as in this script:
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;
});
});Keep the button's label constant, for example "Annual billing", and let aria-pressed carry on or off. If the label changes along with the state, screen readers announce the state twice and confusingly.
Add one polite live region that states the result of the change, rather than marking every price as live. Dozens of announcements at once are unusable.
<p id="billing-status" class="visually-hidden" role="status"></p>document.querySelector("#billing-status").textContent =
"Showing annual prices. Prices are per month, billed yearly.";Also write the billing basis in the visible text next to each price, such as "per month, billed annually". Do not rely on the toggle's state alone.
Test the table
Automated tools catch missing captions, contrast failures, and some header problems, but not whether the table reads sensibly. Use this routine:
- Run an automated checker such as axe or Lighthouse and fix what it reports.
- Tab through the page using only the keyboard. Confirm that you reach the toggle, the scroll area, and each call to action, in a sensible order, with a visible focus ring.
- Turn on a screen reader (VoiceOver, NVDA, or Narrator). Move into the table and navigate cell by cell. Each cell should announce its plan and its feature.
- Zoom to 200% and 400%. Confirm nothing overlaps or disappears.
- Turn off CSS, or view the page in a reader mode. The order should still make sense.
Common errors
| Problem | Effect | Fix |
|---|---|---|
| Empty top-left `th` | Announced as blank or skipped | Add a visually hidden "Feature" label |
| Icon without text | Cell content is lost or unclear | Hide the icon, add visually hidden text |
| `display: none` on helper text | Text is removed for screen readers | Use the visually hidden class |
| Scroll wrapper without focus | Keyboard users cannot scroll | Add `tabindex="0"`, a role, and a name |
| Highlight by color only | Recommendation is invisible to some users | Add the text "Recommended" |
| Toggle label changes with state | Double or confusing announcements | Fixed label with `aria-pressed` |
Exercise
A pricing table uses a green check mark image in each included cell and an empty cell where a feature is missing. Name three changes that make it accessible to a screen reader user.
Show answer
First, replace the images with text or symbols that are hidden from assistive technology with aria-hidden="true", and add visually hidden text such as "Included" and "Not included" in each cell. Second, fill the empty cells with "Not included" text so no cell is blank. Third, make sure the plan names are th elements with scope="col" and the feature names are th elements with scope="row", so each cell is announced with its plan and feature.
Exercise
Your pricing table sits in a wrapper with overflow-x: auto, and keyboard users report they cannot scroll it. What do you add, and why?
Show answer
Add tabindex="0" to the wrapper so it can receive focus, give it role="region" and an accessible name (for example with aria-labelledby pointing at the caption), and provide a visible :focus-visible outline. Once it is focused, the arrow keys scroll it, and screen readers announce it as a named region.