All subjects · Information Technology · WIT12 3 hour practical exam on web development with HTML, CSS and JavaScript

WAI-ARIA: roles, states, live regions and keyboard navigation

Edexcel IAL Information Technology · WIT12 3 hour practical exam on web development with HTML, CSS and JavaScript

WAI-ARIA (Accessible Rich Internet Applications, from the W3C's Web Accessibility Initiative) adds extra meaning for assistive technologies where HTML alone is not enough, especially for components built with JavaScript (spec 11.1.7).

Practise this in the app: instant marking and a fix for every mistake. Free, no email needed to start.

Practise this lesson

Roles: what an element is

A role tells assistive technology what a component is, when the HTML element does not say so:

<div role="button" tabindex="0">Play</div>
<div role="tablist">
  <button role="tab" aria-selected="true" aria-controls="p1">Prices</button>
  <button role="tab" aria-selected="false" aria-controls="p2">Times</button>
</div>
<div role="tabpanel" id="p1">...</div>
<div role="dialog" aria-modal="true" aria-labelledby="dlgTitle">
  <h2 id="dlgTitle">Book a class</h2>
</div>

Other roles include navigation, main, banner, alert, menu and slider. The first rule of ARIA is to use a native HTML element if one exists: a real button is focusable, works with Enter and Space and is announced correctly, with no ARIA needed.

States and properties

AttributeMeaning
aria-labelGives an accessible name when there is no visible text, such as an icon button: aria-label="Close"
aria-labelledbyNames an element using the text of another element (by id)
aria-describedbyLinks extra description, such as a hint or error message, to a control
aria-expandedWhether a collapsible part such as a dropdown is open (true or false)
aria-hiddenHides decorative content from assistive technology
aria-currentMarks the current item, such as the current page in a menu or breadcrumb
aria-selected, aria-checked, aria-disabledThe state of tabs, checkboxes and controls
aria-required, aria-invalidA form field is required, or its value has failed validation

States change as the user interacts, so JavaScript must update them

Live regions and keyboard navigation

// <p id="status" aria-live="polite"></p>
const status = document.getElementById("status");
const menuBtn = document.getElementById("menuBtn");
menuBtn.addEventListener("click", function () {
  const open = menuBtn.getAttribute("aria-expanded") === "true";
  menuBtn.setAttribute("aria-expanded", String(!open));   // keep the state up to date
  document.getElementById("menu").classList.toggle("hidden");
  status.textContent = open ? "Menu closed" : "Menu opened";
});

Worked example

A shopping basket updates its total with JavaScript, but screen reader users do not hear the change. What should be added?

  1. The total is changed dynamically, so it needs to be announced without moving focus.
  2. Make its container a live region: aria-live="polite".

Answer: `<p id="total" aria-live="polite">Total: 12.00</p>`

Key idea: WAI-ARIA adds roles (what it is), states and properties (aria-expanded, aria-label, aria-current, aria-invalid), live regions (aria-live) for dynamic content, and keyboard support with tabindex and key events. Use native HTML first.

Check yourself

  1. Which attribute makes a screen reader announce a message that JavaScript adds to the page?
    • aria-hidden="true"
    • aria-live="polite"
    • role="presentation"
    • tabindex="-1"
    Show answer

    aria-live="polite". A live region announces changes to its content.

  2. An icon-only button shows an X to close a dialog. How can it be given an accessible name?
    • aria-hidden="true"
    • role="img"
    • aria-live="off"
    • aria-label="Close"
    Show answer

    aria-label="Close". aria-label gives a name for screen readers when there is no visible text.

  3. Which attribute should JavaScript update when a dropdown menu opens and closes?
    • aria-label
    • aria-expanded
    • aria-live
    • role
    Show answer

    aria-expanded. aria-expanded tells users whether the controlled content is open.

  4. What is the first rule of using ARIA?
    • Add a role to every element
    • Use div for all controls and add ARIA
    • Use a native HTML element with the required meaning if one exists
    • Use ARIA instead of alt text
    Show answer

    Use a native HTML element with the required meaning if one exists. Native elements such as button come with keyboard support and semantics built in.

  5. What does the role attribute in WAI-ARIA do?
    Show answer

    It tells assistive technologies such as screen readers what kind of component an element is, for example a button or a dialog.. A role defines what an element is (button, tab, dialog, navigation) for assistive technology.

  6. A custom slider made from a div can be clicked but not used from the keyboard. Which combination fixes it?
    • Add aria-hidden="true"
    • Add a title attribute
    • Add tabindex="0" and role="slider", and handle arrow keys with a keydown event
    • Change the div's colour
    Show answer

    Add tabindex="0" and role="slider", and handle arrow keys with a keydown event. It must be focusable, identified and operable with keys.

  7. In a breadcrumb trail, which attribute marks the item for the page the user is on?
    • aria-current="page"
    • aria-selected="page"
    • aria-live="page"
    • role="current"
    Show answer

    aria-current="page". aria-current marks the current item in a set.

Practise with instant feedback

Sources

Last updated 8 November 2026. Spotted a mistake? Tell us.