Sub topic 15
Mapping design intent to native HTML and ARIA
This chapter assumes you can read basic HTML and CSS, know common UI components such as forms, navigation and buttons, and have annotated a wireframe before. It covers the last step of the wireframe stage: turning what you drew into instructions that developers can map onto native HTML first, and onto ARIA only when HTML falls short.
Why the mapping matters
A wireframe shows a box with a label. A developer sees that box and must decide which element to build. If the design says only "button", they might use a <button>, a <div> with a click handler, or a link styled to look like a button. Each choice gives different behavior for keyboard users and screen reader users.
Your annotations should name the intent: what the control does, what it is called, and how it changes state. The developer then picks the element. Native HTML elements already carry a role, a name, keyboard behavior and state. A <div> carries none of these, so every missing piece has to be rebuilt by hand.
The first rule of ARIA
ARIA (Accessible Rich Internet Applications) is a set of attributes that change what assistive technology is told about an element. It adds information. It does not add behavior. Setting role="button" on a <div> tells a screen reader that it is a button, but the element still cannot be reached with Tab and does not respond to Enter or Space until someone writes that code.
The W3C guidance on using ARIA gives an order of preference:
- Use a native HTML element that already has the semantics and behavior you need.
- If none exists, use ARIA together with the keyboard handling and focus management the pattern requires.
- Never use ARIA to contradict a native element's meaning, such as
role="heading"on a<button>.
The common phrase "no ARIA is better than bad ARIA" follows from this. Incorrect ARIA gives screen reader users false information, and it is harder to notice than missing markup.
A mapping table for common wireframe elements
Use a table like this in your handoff notes. It lets a developer see your intent and the expected element in one place.
| Design intent in the wireframe | Native HTML to request | Notes for the annotation |
|---|---|---|
| Action on the current page (save, open a dialog) | `<button type="button">` | Activates with Enter and Space |
| Go to another page or location | `<a href>` | Activates with Enter only. Link text must make sense out of context |
| Submit a form | `<button type="submit">` inside `<form>` | Enter in a text field also submits |
| Text field with a label | `<label for>` plus `<input>` | Label stays visible. Pick the correct `type` and `autocomplete` |
| Choose one of a few options | `<fieldset>` with `<legend>` and radio inputs | The legend names the group |
| Yes or no, or select several | `<input type="checkbox">` | State is built in, so no `aria-checked` is needed |
| Choose from a long list | `<select>` | Use a custom listbox only with a stated reason |
| Page regions | `<header>`, `<nav>`, `<main>`, `<footer>`, `<aside>` | Label a region when a page has more than one of the same kind |
| Section title | `<h1>` to `<h6>` | Level reflects the outline, not the visual size |
| Tabular data | `<table>` with `<th scope>` | Do not use tables for layout |
| Disclosure that shows or hides content | `<button aria-expanded>` controlling a region, or `<details>` | `<details>` needs no script |
Where native HTML is not enough
Some wireframe patterns have no complete native equivalent, or the native version cannot meet the design. In these cases ARIA fills a gap. The common ones are:
- Tabs, menus and tree views, which have roles (
tablist,menu,tree) and an expected keyboard model. - Live updates, such as a "Saved" message that appears without moving focus.
- State on custom controls, such as a toggle button that is on or off.
- Extra relationships, such as tying hint text to an input.
When you specify one of these, state four things in the annotation: the role, the accessible name, the states that change, and the keyboard behavior. Leaving out the keyboard behavior is the most common gap, because ARIA does not supply it.
Accessible name, role and state
Every interactive element needs a name, a role and a state. Assistive technology reads these three pieces from the accessibility tree, which the browser builds from the HTML.
- Name: what the element is called. It comes from visible text, a
<label>,aria-labelledbyoraria-label. - Role: what kind of thing it is, such as button, link or checkbox.
- State: its current condition, such as expanded, checked, disabled or invalid.
Prefer a name that comes from visible text. WCAG 2.5.3 (Label in Name) requires the accessible name of a control to contain its visible label, so that people using speech input can say what they see. A button that shows "Search" but has aria-label="Find items" breaks this.
A worked example: a toggle disclosure
Suppose your wireframe shows a "Shipping details" row that expands to reveal an address form. The annotation reads: "Disclosure. Button toggles panel. Panel starts collapsed. Focus stays on the button."
The developer can build this with a native button and a small amount of ARIA.
<h2>
<button type="button" aria-expanded="false" aria-controls="shipping-panel">
Shipping details
</button>
</h2>
<div id="shipping-panel" hidden>
<p>Enter the address where we should deliver your order.</p>
</div>
<script>
const button = document.querySelector('[aria-controls="shipping-panel"]');
const panel = document.getElementById("shipping-panel");
button.addEventListener("click", () => {
const isOpen = button.getAttribute("aria-expanded") === "true";
button.setAttribute("aria-expanded", String(!isOpen));
panel.hidden = isOpen;
});
</script>Check what each part does:
<button>gives focus, Enter and Space activation, and the button role without any extra code.aria-expandedis the one piece of ARIA that is needed. It reports the open or closed state.- The
hiddenattribute removes the panel from view and from the accessibility tree while collapsed. - The heading wraps the button, so the section still appears in the heading outline.
The simpler option is <details> with <summary>, which gives the same behavior with no script. Prefer it when the design does not need custom animation or grouping.
Naming and describing
ARIA offers several ways to name or describe an element. They do different jobs.
| Attribute | Purpose | Use when |
|---|---|---|
| `aria-label` | Supplies a name as a string | There is no visible text, such as an icon-only button. The string is not visible, so it is not translated by some tools |
| `aria-labelledby` | Names an element from other visible text by id | A heading already names the region |
| `aria-describedby` | Adds a longer description after the name | Hints and error messages for inputs |
The earlier form example in this tutorial used aria-describedby="email-hint email-error". The hint and error are read after the field's name, and the field keeps its visible <label>. A native label should be used whenever one is possible, and aria-label kept for cases such as an icon button.
<button type="button" aria-label="Close dialog">
<svg aria-hidden="true" focusable="false" width="16" height="16">
<path d="M2 2l12 12M14 2L2 14" stroke="currentColor" stroke-width="2" />
</svg>
</button>Here the icon is decorative to the user, so aria-hidden="true" hides it from assistive technology and the button name comes from aria-label. The wireframe annotation for this control should state the name ("Close dialog") so the developer does not invent one.
Common errors
- Redundant roles.
<button role="button">or<nav role="navigation">add nothing. Leave them out. - Role without behavior. A
<div role="button">that cannot be focused or activated by keyboard. Request a native<button>instead. aria-hiddenon focusable elements. The element can still receive focus but is invisible to a screen reader, so users land on something unnamed.- Mismatched state.
aria-expandedthat is not updated when the panel opens, so the announced state is wrong. - Heading levels chosen for size. Pick the level from the outline, then style it with CSS.
- Hiding with
display: noneand expecting it to be read. Content hidden this way is removed from the accessibility tree. Use it only for content that should be absent for everyone. - Placeholder text as the label. It disappears on input and has low contrast in many styles. Request a visible
<label>.
Writing the annotation
A good annotation names intent and leaves the element choice open when more than one native option works. Use a short, repeatable format.
- Name the component and its purpose.
- State the preferred native element.
- Give the accessible name, using the visible text where possible.
- List states that change and what triggers them.
- Describe keyboard behavior and where focus goes after the action.
For the shipping example: "Disclosure. Native button inside the h2. Name: Shipping details. State: expanded or collapsed, starts collapsed. Enter or Space toggles. Focus stays on the button."
Verify the handoff
After the build, check the result against the annotation. Tab to each control and operate it with the keyboard. Inspect the accessibility tree in your browser's developer tools to confirm the name, role and state match what you wrote. Run an automated checker too, but treat it as partial: automated tools find only some of the problems, and they cannot judge whether a name makes sense.
Exercise
A wireframe shows a "Filters" control that opens a panel of checkboxes. A developer builds it as <div role="button" aria-expanded="false">Filters</div>. Name two things that are still missing, and write the better element choice.
Show answer
The div cannot be focused with Tab and does not respond to Enter or Space, because a role adds neither. Use <button type="button" aria-expanded="false" aria-controls="filters-panel">Filters</button>. The native button supplies focus and key activation. Only aria-expanded and aria-controls remain as ARIA, and the script must update aria-expanded when the panel opens or closes.
Exercise
A close button in a dialog shows only an "X" icon. The wireframe annotation says nothing about its name. Write the annotation line you would add, and say which attribute supplies the name.
Show answer
"Close button. Native button. Name: Close dialog. Enter or Space closes the dialog and returns focus to the control that opened it." The name comes from aria-label="Close dialog" on the button, and the icon should be hidden with aria-hidden="true" so it is not announced.