Advanced

Markup that serves everyone

A page is read by people who cannot see it, cannot use a mouse, or cannot hear audio. The markup decides whether those readers can follow it, and most of the fixes are small and specific: names, order, and alternatives.

What you will see

Announced as 'Open menu, button'. The empty alt stops the image being announced twice, which is the pairing to learn.

About 1 min of reading

Try It

Fix an icon button.

1

Icon only

Before you run it, say out loud what it will print. Then open the answer.

What it prints
A screen reader announces 'button' with no name - the reader does not know what it does.
2

Named

Before you run it, say out loud what it will print. Then open the answer.

What it prints
Announced as 'Open menu, button'. The empty alt stops the image being announced twice, which is the pairing to learn.

Data Flow

The document carries the alternatives.
1 Write the reading order in HTML
↓
2 Name every control
↓
3 Give images their decision
↓
4 Check contrast and keyboard order
Why this works
Keyboard first

Everything reachable by pointer has to be reachable by keyboard, in a sensible order. Testing the page by tabbing through it takes a minute and finds most of what an audit would report.

Contrast is a number

Text against its background needs enough contrast to be read, and that ratio is computable. Choosing colours by eye is where the failures are, and checking the ratio is where the fix is.

Examples

Alt text is a decision

An image that carries information needs those words in alt. An image that is decoration needs an empty alt so a reader is not told about something meaningless. Both answers are correct and both are choices.

Reading order is document order

A reader follows the order the elements appear, not the order they are painted. Reordering visually with CSS while leaving the source order wrong is the bug that makes a page confusing.

Controls need names

A button whose only label is an icon gives a reader the word 'button'. The accessible name is what is announced, and it belongs in the markup even when the design shows only an icon.

Words this lesson uses

Each one is defined here on this site. Open the entry for the full definition and the other words it points at.

← Positioning and stacking
Previous Lesson
Positioning and stacking
Next Lesson
A stylesheet that survives change
A stylesheet that survives change →