Lesson 10 of 23
In progress
Accessibility basics that cover most of the page
Make a page work with a keyboard, a screen reader and at 200 percent zoom, without adding a single ARIA attribute.
Accessibility is not a separate version of the site. It is what happens when the structure, the contrast and the keyboard behaviour are right, and most of it comes from using the elements you have already learned.
What you will learn
- Test a page with only a keyboard and at 200 percent zoom.
- Use semantic HTML before reaching for ARIA.
- Check the four failures that block the most people.
Start with the keyboard
Put the mouse away and press Tab from the top of the page. You should reach every interactive element in a logical order, see where focus is, and be able to activate it with Enter or Space.
Three common failures appear immediately:
- A
divwith a click handler is skipped entirely. - Focus disappears because
outline: nonewas set without a replacement. - Tab order jumps around because elements are positioned visually but not in source order.
The fix for the first is a real button. The second needs a visible focus style, which the CSS module builds. The third is solved by keeping the DOM order close to the visual order.
A skip link is the standard first element on a content-heavy page:
Editable. Runs in your browser.
<header>
<nav aria-label="Main">
<a href="/">Home</a>
</nav>
</header>
<main id="content">
<h1>Accessible by default</h1>
<p>The skip link is the first thing keyboard users reach.</p>
</main>
Press Run to see the output.
Semantics before ARIA
The first rule of ARIA is not to use ARIA when a native element already does the job. A button is focusable, announces its role and responds to keys. role="button" on a div announces the role and does none of the rest.
Use ARIA to supply a name or a relationship that HTML cannot express: aria-label on an icon-only button, aria-describedby for a hint, aria-current="page" on the active navigation link. Then test with a screen reader, because ARIA that lies is worse than no ARIA.
A page with headings, landmarks, labels and alt text is already usable by most assistive technology. That is the bulk of the work.
Contrast and colour
Body text needs a contrast ratio of at least 4.5:1 against its background; large text needs 3:1. Placeholder text, disabled labels and text over photos are where this usually fails.
Never use colour alone to carry meaning. An error marked only with red is invisible to someone with colour blindness; add text and an icon. A link styled only by colour in a paragraph is hard to spot; keep the underline or add another cue.
Dark mode needs its own contrast check. A palette that passes on white can fail when the background becomes navy and the text keeps the same grey.
Zoom and reflow
Set the browser to 200 percent and check that nothing important disappears. Content should reflow into a single column rather than forcing horizontal scrolling. Text should not be clipped by fixed-height containers.
The usual causes are fixed pixel widths, overflow: hidden on text containers, and absolutely positioned elements that overlap when the font grows. The CSS module covers the fluid alternatives.
Images, forms and motion, briefly
- Informative images need alt text; decorative ones need
alt="". - Every input needs a label; errors need to be announced, not just coloured.
- Animation should respect
prefers-reduced-motion, because motion can trigger nausea and migraine. - Video needs captions, and audio needs a transcript.
A short manual test
Run this before calling a page done:
- Tab through the page. Is every control reachable and visible when focused?
- Zoom to 200 percent. Does the layout still work?
- Turn on high contrast or a dark-mode emulation. Is any text lost?
- Read the headings in order. Do they describe the page?
- Fill the form wrongly. Is the error announced and specific?
Automated tools catch perhaps a third of issues. The keyboard and zoom checks catch most of the rest.
Adding aria-hidden="true" to something focusable, such as a button inside a hidden menu, leaves a control that keyboard users can focus but screen readers cannot announce. Hide it properly with the hidden attribute or display: none until it is available, and keep focus out of it while hidden.
Audit a page with three deliberate problems: an icon-only button with no name, a paragraph with grey text on a light grey background, and a link that only says "click here". Fix each one and say which fix needed ARIA and which did not.
Show solution
Editable. Runs in your browser.
<p style="color:#1f2430;background:#f4f4f6">
This text is dark enough to read comfortably.
</p>
<p>
Read the <a href="/guides/flexbox">guide to Flexbox</a>.
</p>
Press Run to see the output.
The button needs aria-label because the visible character carries no name. The text needs a darker colour, which is a CSS decision, not ARIA. The link needs descriptive text, which is an HTML content fix.
Recap
- Keyboard order, visible focus and a skip link make the page navigable without a mouse.
- Semantic HTML covers most accessibility; ARIA supplies names and relationships, not behaviour.
- Check contrast, 200 percent zoom and reduced motion before shipping.
Next, you will fill in the document head so the page is described correctly to browsers and search engines.
Do I need to support Internet Explorer?
Is a screen reader test mandatory?
Progress is saved in this browser only. No account, no email.