lesson
30 min

Fix the Common Problems

Alt text, form labels, headings, contrast, and keyboard access fix many of the barriers people meet.

What you will learn

By the end of this lesson, you can find and fix five common accessibility problems in HTML.

Five common problems

1. Missing alt text

Alt text is a short description of an image for people who cannot see it. Screen readers read it out loud. Write what the image shows and why it matters. If an image is only decoration, use empty alt text (alt="") so screen readers skip it.

2. Form fields without labels

Every form field needs a visible label tied to it with the label element. Placeholder text inside a box is not a label. It disappears when you type, and screen readers may not read it.

3. Headings out of order

Screen reader users jump between headings to scan a page. Use one main heading, then h2 for sections and h3 under those. Do not pick headings by how big they look.

4. Low color contrast

Light gray text on white is hard to read for many people. WCAG AA asks for a contrast ratio of at least 4.5 to 1 for normal text. Free contrast checkers tell you if you pass. Also, never use color alone to show meaning. Add words like "Required" or "Error."

5. Things that only work with a mouse

Every button and link must work with the keyboard. Use real button and a elements, not clickable boxes. Never remove the focus outline, which shows keyboard users where they are.

Fix a broken form

The form below has problems. Fix them in the editor. If you use a keyboard, press Esc, then Tab, to leave the editor.

Fix the sign-up form

Find and fix: 1) the image has no alt text, 2) the inputs have no labels, 3) the heading jumps from h1 to h4, 4) the gray text is too light, 5) the 'Submit' is a div, not a button. The fixed version is in the next section if you get stuck.

Loading the code editor...

Press Esc, then Tab, to move focus out of the editor.

One way to fix it

<h1>Free Saturday Coding Club</h1>
<img src="club.jpg" alt="Teens and a mentor working on laptops at a library table">
<h2>Sign up</h2>
<p class="note">All fields are required.</p>
<label for="guardian">Parent or guardian name</label>
<input id="guardian" type="text" autocomplete="name">
<label for="phone">Phone</label>
<input id="phone" type="tel" autocomplete="tel">
<button type="submit">Submit</button>

And in the CSS, change .note to a darker color such as #595959.

Five fixes

0 of 5 done

Go deeper: Accessibility: Build Products Everyone Can Use (and Love)

Ask. Answer. Build together.