Lesson 34 of 51 · Module 5, lesson 7 of 7 · 5 min

Accessibility basics: test without a mouse

Check your page with the keyboard, the headings, the landmarks and a screen reader, in five quick steps.

What you'll learn

  • Five quick checks that find most accessibility problems in a page
  • How to test your page with only the keyboard
  • How to check your headings, landmarks and alt text with the developer tools

Why this matters

Accessibility means that people with disabilities can use your website: people who are blind, who cannot use a mouse, who see colours differently, or who need larger text. That is a very large group of people — and many of the same fixes also help people on phones, on slow connections, or in bright sunlight. In many countries, accessibility is also a legal requirement for public and business websites.

The good news: correct HTML — the HTML in this course — does most of the work. This lesson gives you a short routine to check it.

Check 1: Only the keyboard

Many people cannot use a mouse. They move through a page with the Tab key.

A small page with numbered focus stops: 1 the Home link, 2 the Recipes link, 3 the "full recipe" link, which has a visible outline, 4 the email field, and 5 the Subscribe button. Tab moves forward to the next link, field or button; Shift plus Tab moves back; Enter follows a link or presses a button; Space ticks a box. You should always see where you are and reach everything in a sensible order.

Open your page, click the address bar, then press Tab again and again:

  • Can you reach every link, field and button?
  • Can you always see where you are (a visible outline)?
  • Is the order sensible — top to bottom, left to right?
  • Does Enter follow a link, and Space tick a checkbox?

(On macOS Safari, Tab skips links by default. Use Option + Tab, or turn on Press Tab to highlight each item on a webpage in Safari › Settings › Advanced.)

Check 2: The headings

Headings are the table of contents for screen reader users. Open the developer tools and look at every <h1>–<h6> in the Elements panel, or use a free "headings map" browser extension. Ask:

  • Is there exactly one <h1>, saying what the page is about?
  • Do the levels go down one step at a time?
  • Does each heading say what its section contains?

Check 3: The landmarks

Is the page divided into <header>, <nav>, <main> and <footer>? Is there exactly one <main>? In Chrome or Edge, select an element in the developer tools and look at the Accessibility pane to see its role.

Check 4: Every image

  • Does every <img> have an alt?
  • Does it describe the image, in words that make sense read aloud?
  • Is it alt="" for decoration?

A quick way: turn images off, or zoom out and read only the alt texts in the Elements panel. Would the page still make sense?

  • Does every link make sense on its own? ("Read the soup recipe", not "click here".)
  • Does <html> have the right lang?
  • Is important information given in words — not only in colour, bold, an emoji or a picture?

Listen to your page

Every computer and phone has a free screen reader. Try one for five minutes on your own page:

  • Windows: Narrator — press Windows key + Ctrl + Enter to turn it on or off.
  • macOS: VoiceOver — press Command + F5 to turn it on or off.
  • Android: TalkBack; iPhone: VoiceOver — both in the phone's Accessibility settings.

Listen to how your headings, links and images are read. It changes how you write HTML.

A complete example to test

html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Tomato soup — Home Kitchen</title>
</head>
<body>
  <header>
    <nav>
      <ul>
        <li><a href="index.html">Home</a></li>
        <li><a href="recipes.html">Recipes</a></li>
      </ul>
    </nav>
  </header>
  <main>
    <h1>Tomato soup</h1>
    <img src="images/tomato-soup.jpg" alt="A white bowl of hot tomato soup" width="300" height="200">
    <p>Read the <a href="#steps">cooking steps</a> below.</p>
    <h2 id="steps">Steps</h2>
    <ol>
      <li>Cut the tomatoes.</li>
      <li>Cook them for twenty minutes.</li>
    </ol>
  </main>
  <footer>
    <p>Home Kitchen</p>
  </footer>
</body>
</html>

A small accessible page: a bulleted menu with Home and Recipes, the heading "Tomato soup", a picture of a bowl of soup, a sentence with the link "cooking steps", the heading "Steps" with two numbered steps, and the footer "Home Kitchen".

Try it yourself

  1. Select the example and choose Try it. Click inside the preview, then press Tab repeatedly. Watch which items get an outline.
  2. Run all five checks on your own about.html and recipe.html. Write down one problem you find and fix it.

Common mistakes

  • Testing only with a mouse. Keyboard problems stay hidden. Fix: do Check 1 on every page.
  • Removing the focus outline because it "looks ugly". Keyboard users get lost. Fix: never remove it; you can restyle it with CSS later.
  • Thinking accessibility is extra work for later. Fixing it later is harder. Fix: write correct HTML from the start — you already are.

Check yourself

  1. Which key moves forward through the links and fields of a page?
  2. Name three of the five checks.
  3. How do you start the screen reader on your own computer?

Answers

  1. Tab.
  2. Any three of: keyboard only; headings; landmarks; images and alt text; links, language and words.
  3. Windows: Narrator, Windows key + Ctrl + Enter. macOS: VoiceOver, Command + F5.

Next: put the structure elements together in the practice exercise, and test the result with the five checks.

Practice project

a semantic recipe page

Goal: rebuild your recipe page with landmarks and structure, then test it like a keyboard and screen reader user.

Your website after this module

Outcome: your site gets a real structure: a header with your site name and menu, one main area and a footer, and keyboard and screen reader users can use it.

Your my-website folder: the same pages, with recipe.html rebuilt. You add the same header and footer to every page in module 7.

Own topic? Rebuild your article page the same way: an image with a caption, two sections and a tip.

Warm up first (optional): Write a Recipe Page and Semantic Blog Page in Work Space, if it is in your menu. Work Space checks your code at once, so you know you are ready before you build.

What to do

Start from your recipe.html (from the recipe exercise) or write a new one. The page must have:

  1. The full skeleton, with a <title> like Dish name — Your site name.
  2. A <header> with your site name (a paragraph) and a <nav> holding a list of links to your other pages.
  3. One <main>, holding an <article> for the recipe:
    • the <h1> with the dish name;
    • a <figure> with an image, a good alt and a <figcaption>;
    • a <section> "Ingredients" with a bulleted list;
    • a <section> "Steps" with a numbered list.
  4. An <aside> with a tip, with its own heading.
  5. A <footer> with your name.
  6. At least one class name that describes a purpose (for example class="tip").

Then run the five checks from Accessibility basics: keyboard, headings, landmarks, images, links and language.

Paste your code into the box. Below the code, in a comment, write one thing the checks helped you find or confirm. Then submit.

Checklist before you submit

  • Exactly one <main> and one <h1>.
  • Every section and aside has a heading, and the levels do not skip.
  • You can reach every link with Tab and always see where you are.
  • No <div> where a meaningful element would fit.

Your mentor reviews every submission. The exercise counts as done when it is marked Passed.

Starter code

html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>DISH NAME — SITE NAME</title>
</head>
<body>
  <header>
    <p>SITE NAME</p>
    <nav>
      <ul>
        <li><a href="index.html">Home</a></li>
      </ul>
    </nav>
  </header>

  <main>
    <article>
      <h1>DISH NAME</h1>
    </article>
  </main>

  <footer>
    <p>YOUR NAME</p>
  </footer>
</body>
</html>

<!-- What the checks helped me find: -->

Build it in your own folder, on your computer. ZAM students hand this project in on their dashboard, and their mentor reviews it.

Chat with us on WhatsApp