Skip to content

Menu

Web Accessibility Cheat Sheet: ARIA, WCAG 2.2 and Contrast

Checked against WCAG and WAI-ARIA WCAG 2.2 (W3C Recommendation, 12 Dec 2024 edition) and WAI-ARIA 1.2 (Recommendation, 6 Jun 2023) on 28 November 2026. Each section links to the official docs it was checked against.

This sheet is for front-end developers who need to pass a WCAG 2.2 AA audit without reading the whole spec. It follows the W3C texts of WCAG 2.2 (current edition dated 12 December 2024) and WAI-ARIA 1.2. Thresholds and attribute values are quoted from those documents; the markup rows are standard HTML and ARIA, not test results from a screen reader, so they are marked untested.

When to use what

Use a native element before you reach for ARIA. A <button> gives you the role, focus, Enter and Space handling and the disabled state for free; a <div role="button"> gives you only the role and leaves the rest to you. That is the first rule in the W3C's Using ARIA note, and most audit failures we see are broken copies of native controls.

Add ARIA when HTML has no element for the pattern (tabs, a disclosure that controls another region, a live status message) or when you need to name something that has no visible text, such as an icon-only button. For names, visible text wins: aria-labelledby pointing at text on screen keeps the spoken name in sync with what sighted users read, which is what 2.5.3 Label in Name asks for. Our ARIA attribute reference lists which attributes each role allows, and the ARIA label generator helps write names for icon buttons.

Automated checkers catch missing alt text and low contrast but not focus order or confusing names, so plan a keyboard pass by hand. The accessibility testing post describes a split that works, and the focus order tester shows the tab sequence of a snippet.

<button type="button">Save</button>

Rule 1: use the native element when one exists instead of role="button" on a div

From the docs, not run by us
<div role="tab"><h2>Billing</h2></div>

Rule 2: don't change native semantics; wrap the heading rather than putting role="tab" on the h2

From the docs, not run by us
Enter and Space on role="button"

Rule 3: any custom ARIA control must work from the keyboard

From the docs, not run by us
<button aria-hidden="true">

Rule 4 violation: never hide a focusable element or its ancestor from assistive tech

From the docs, not run by us
<label for="email">Email</label><input id="email">

Name a form field with a visible label, the most reliable method

From the docs, not run by us
<button aria-label="Close"><svg aria-hidden="true">…</svg></button>

Name an icon-only button and hide the decorative icon

Try it: ARIA Label GeneratorFrom the docs, not run by us
aria-labelledby="dlg-title"

Name an element from visible text elsewhere, by id; takes a list of ids

From the docs, not run by us
aria-describedby="pw-hint"

Attach longer help text, read after the name; the referenced elements form the whole description

From the docs, not run by us
<img src="chart.png" alt="Sales rose 12% in Q3">

Give an informative image a text alternative (1.1.1); use alt="" for decoration

From the docs, not run by us

Values below are the ones WAI-ARIA 1.2 defines. Check allowed roles per attribute in the ARIA attribute reference.

aria-expanded="false"

On a disclosure button: the region it controls is collapsed; true when open

Try it: aria-attribute-referenceFrom the docs, not run by us
aria-controls="menu-1"

Point to the element whose content this control changes (id list)

From the docs, not run by us
aria-current="page"

Mark the current link in a nav; values page, step, location, date, time, true, false

From the docs, not run by us
aria-pressed="true"

Turn a button into a toggle button; values true, false, mixed

From the docs, not run by us
aria-checked="mixed"

Tri-state checkbox; mixed isn't valid on radio or switch

From the docs, not run by us
aria-selected="true"

Mark the selected tab in a tablist; other tabs get false

From the docs, not run by us
aria-invalid="true"

Flag a field that failed validation; also grammar or spelling

From the docs, not run by us
aria-live="polite"

Announce changes at the next pause; assertive interrupts, off is the default

From the docs, not run by us
aria-hidden="true"

Remove decorative content from the accessibility tree; never on focusable elements

From the docs, not run by us
1.1.1 Non-text Content (A)

Every image, icon and control has a text alternative that serves the same purpose

From the docs, not run by us
1.3.1 Info and Relationships (A)

Headings, lists, tables and labels are in the markup, not only in styling

From the docs, not run by us
1.4.10 Reflow (AA)

Content works at 320 CSS px wide without horizontal scrolling (a 1280 px window at 400% zoom)

From the docs, not run by us
1.4.12 Text Spacing (AA)

Nothing breaks when users set line height 1.5, paragraph spacing 2, letter 0.12 and word 0.16 times the font size

From the docs, not run by us
2.1.1 Keyboard (A)

Everything works with a keyboard alone

Try it: focus-order-testerFrom the docs, not run by us
2.4.3 Focus Order (A)

Tab order follows the meaning of the page

From the docs, not run by us
2.4.7 Focus Visible (AA)

Keyboard focus always has a visible indicator

From the docs, not run by us
2.5.3 Label in Name (A)

The accessible name contains the visible label text

From the docs, not run by us
3.3.2 Labels or Instructions (A)

Inputs that need user data have labels or instructions

From the docs, not run by us
4.1.2 Name, Role, Value (A)

Custom controls expose name, role and state to assistive tech

From the docs, not run by us
4.1.3 Status Messages (AA)

Status updates are announced without moving focus, for example via role="status"

From the docs, not run by us
2.4.11 Focus Not Obscured (Minimum) (AA)

A focused element must not be entirely hidden by your own sticky headers, banners or chat widgets

From the docs, not run by us
2.5.7 Dragging Movements (AA)

Anything done by dragging also works with single clicks or taps, unless dragging is essential

From the docs, not run by us
2.5.8 Target Size (Minimum) (AA)

Pointer targets are at least 24 by 24 CSS px, or spaced so a 24 px circle on each doesn't overlap another

From the docs, not run by us
3.2.6 Consistent Help (A)

Help links or contact options repeated across pages stay in the same relative order

From the docs, not run by us
3.3.7 Redundant Entry (A)

Don't make users retype what they already entered in the same process; prefill or offer it

From the docs, not run by us
3.3.8 Accessible Authentication (Minimum) (AA)

Login can't rely on remembering or transcribing unless paste and password managers work or there's an alternative

From the docs, not run by us
4.5:1

Minimum for normal body text at AA (1.4.3)

Try it: Contrast Ratio CheckerFrom the docs, not run by us
3:1

Minimum for large text at AA: at least 18 pt, or 14 pt bold

Try it: Contrast Ratio CheckerFrom the docs, not run by us
3:1 non-text (1.4.11)

Minimum for UI component boundaries, focus rings and meaningful icons against adjacent colours

From the docs, not run by us
7:1 and 4.5:1

AAA (1.4.6) for normal and large text respectively

From the docs, not run by us

Worked example: Turn a div toggle into an accessible disclosure

A common audit finding: a clickable div that opens a filter panel.

<!-- before -->
<div class="toggle" onclick="togglePanel()">Filters ▾</div>
<div id="filters" hidden>…</div>

<!-- after -->
<button type="button" aria-expanded="false" aria-controls="filters">Filters</button>
<div id="filters" hidden>…</div>
<script>
  const btn = document.querySelector('[aria-controls="filters"]');
  btn.addEventListener('click', () => {
    const open = btn.getAttribute('aria-expanded') === 'true';
    btn.setAttribute('aria-expanded', String(!open));
    document.getElementById('filters').hidden = open;
  });
</script>

The before version fails 2.1.1 (no keyboard access, since a div isn't focusable) and 4.1.2 (no role or state exposed). Swapping in a button fixes focus and Enter and Space handling in one go, which is the first rule of ARIA at work. aria-expanded tells a screen reader whether the panel is open, and the script keeps it in sync with hidden. We didn't run this through a screen reader for this sheet; when you test it, the button should be announced with its name, its button role and a collapsed or expanded state, and the state should change each time you press Space.

Common mistakes

  • Marking the active tab with aria-current instead of aria-selected.

    Use aria-selected="true" on the active tab and false on the others; the ARIA spec says not to swap the two where they mean the same thing.

  • Adding role="button" to a div and stopping there.

    Use a real <button>; if you can't, add tabindex="0" and handle Enter and Space yourself.

  • Removing focus outlines with outline: none for looks.

    Style a visible :focus-visible ring with at least 3:1 contrast against the background.

  • A sticky cookie banner or header covering the focused link as users tab down the page.

    Add scroll-padding-top equal to the header height and let banners be dismissed, to meet 2.4.11.

  • Blocking paste in password or one-time code fields.

    Allow paste and autocomplete so password managers work; 3.3.8 treats that as the help mechanism.

  • Making a visible label say "Search" while aria-label says "Find products".

    Keep the visible words in the accessible name so voice users can say what they see (2.5.3).

Sources

How we research: where our facts come from, how often we re-check them, and why no one can pay for a review or a verdict.

What changed in AI dev tools, once a month

Renames, shutdowns, pricing changes and new MCP setups, each with a source.

Subscribe
Reviews and commentsShow

Comments

Sign in to leave a comment.

Loading comments…