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).
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
| Attribute | Meaning |
|---|---|
| aria-label | Gives an accessible name when there is no visible text, such as an icon button: aria-label="Close" |
| aria-labelledby | Names an element using the text of another element (by id) |
| aria-describedby | Links extra description, such as a hint or error message, to a control |
| aria-expanded | Whether a collapsible part such as a dropdown is open (true or false) |
| aria-hidden | Hides decorative content from assistive technology |
| aria-current | Marks the current item, such as the current page in a menu or breadcrumb |
| aria-selected, aria-checked, aria-disabled | The state of tabs, checkboxes and controls |
| aria-required, aria-invalid | A 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";
});- A live region (aria-live="polite", or "assertive" for urgent messages, or role="alert") makes a screen reader announce content that JavaScript changes, such as a basket total, a validation message or new search results, without the user moving to it.
- Enhanced keyboard navigation: every custom control must be reachable with Tab (tabindex="0"), operable with Enter, Space and the arrow keys (handled with keydown events), show a visible focus style, and keep focus inside an open modal dialog, returning it to the trigger button when the dialog closes.
Worked example
A shopping basket updates its total with JavaScript, but screen reader users do not hear the change. What should be added?
- The total is changed dynamically, so it needs to be announced without moving focus.
- Make its container a live region: aria-live="polite".
Answer: `<p id="total" aria-live="polite">Total: 12.00</p>`
Check yourself
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
Sources
- Pearson Edexcel International Advanced Subsidiary/Advanced Level in Information Technology specification (first teaching 2018), Unit 2 Topics 7 to 11
- Pearson qualifications: Edexcel International Advanced Level Information Technology (2018)
Last updated 8 November 2026. Spotted a mistake? Tell us.