Fixing ARIA errors: invalid attributes, missing states and duplicate IDs
The most common ARIA findings explained: aria-allowed-attr, aria-required-attr, aria-valid-attr-value and duplicate-id-aria, with causes and safe fixes.
In short
ARIA attributes tell screen readers what an element is and what state it is in. Used incorrectly, they cause errors that would not exist without ARIA: an attribute does not fit the role (aria-allowed-attr), a required state is missing (aria-required-attr), a value is invalid or points nowhere (aria-valid-attr-value), or a referenced ID occurs more than once (duplicate-id-aria). The best fix is often less ARIA: use native HTML elements and only add ARIA where HTML is not enough.
Why ARIA errors weigh heavily
ARIA only changes what assistive technologies announce, not how an element behaves. An attribute such as role="checkbox" makes a <div> neither operable nor focusable, yet it promises exactly that. The W3C guidance on the ARIA patterns sums it up: no ARIA is better than bad ARIA. Accordingly, the first rule of “Using ARIA” says: if a native HTML element with the meaning and behaviour you need exists, use it.
The axe rules described here belong to WCAG success criterion 4.1.2 “Name, Role, Value” (Level A). They check syntax: whether attributes, values and references are valid. Whether a state such as aria-expanded actually changes when something opens can only be found out by trying it.
aria-allowed-attr and aria-prohibited-attr: the attribute does not fit the role
Each role only allows certain ARIA attributes. A common example is marking the current page in the navigation with <a href="/contact" aria-selected="true">. aria-selected is not intended for links; aria-current="page" is correct. <button aria-checked="true"> is not allowed either: a toggle button uses aria-pressed, an on/off switch uses role="switch" with aria-checked, and a choice is best made with a real checkbox.
aria-prohibited-attr reports names on elements that must not have one, such as aria-label on a <div> or <span> without a role. Screen readers then often ignore it. Move the label to a suitable element or write it as visible text.
aria-required-attr: a required state is missing
Some roles are incomplete without certain states. role="checkbox" and role="switch" need aria-checked, and role="slider" needs aria-valuenow. If the attribute is missing, nobody learns whether the option is selected or which value is set.
Add the attribute and update it with your script on every change, for example <div role="checkbox" aria-checked="false" tabindex="0">. The native element is better and usually shorter: <input type="checkbox"> or <input type="range"> come with state, keyboard operation and focus built in.
aria-valid-attr-value and aria-valid-attr: invalid values and typos
- Wrong boolean values: aria-expanded="yes" or aria-hidden="hidden" are invalid; "true" and "false" are allowed.
- Unknown tokens: aria-current="active" is invalid; the defined values include page, step, location, date, time, true and false.
- References to nowhere: aria-labelledby, aria-describedby or aria-controls point to an id that does not exist on the page, for example after a rename or with IDs regenerated on every render.
- Typos in the attribute name: aria-labeledby with one l does not exist and is reported by aria-valid-attr; aria-labelledby is correct.
duplicate-id-aria: duplicate IDs in labels
IDs referenced by a <label for>, aria-labelledby or aria-describedby must be unique on the page. If such an id occurs twice, the browser usually uses the first matching element, and one field gets the label of another. Typical causes are components that appear twice in the code for mobile and desktop views, the same newsletter form in the sidebar and the footer, or copied blocks.
So generate unique IDs per instance, in React for example with useId(), in WordPress PHP with wp_unique_id(). After the fix, check that every label is announced with the right field.
aria-hidden and focus
aria-hidden-focus reports areas with aria-hidden="true" that still contain focusable elements. Typical examples are closed off-canvas menus, cloned slides in sliders and dialogs in the background. Keyboard users then land on links that screen readers keep quiet about. Hide closed areas completely, for example with hidden or display:none, or use the inert attribute, which makes content unfocusable and invisible to assistive technologies at the same time.
Approach and verification
- Group the findings by component; one faulty menu produces the same message on every page.
- Look up the matching pattern in the W3C ARIA Authoring Practices and first check whether a native HTML element is enough.
- Fix the component at its source, in the template, theme or library, instead of patching individual pages.
- Check role, name and states in the developer tools under “Accessibility”.
- Operate the component with the keyboard and a screen reader and check that states change when opening, closing and selecting.
- Run the website check again.
Sources & review status
Here you’ll find the original sources for this article. Last checked on .
- W3C: Using ARIA (rules for using ARIA)
- W3C WAI-ARIA APG: Read me first
- W3C: WAI-ARIA 1.2, roles and attributes
- W3C: Understanding Name, Role, Value (4.1.2)
- Deque: axe rule aria-allowed-attr
- Deque: axe rule duplicate-id-aria
Legal requirements depend on the country, the provider and the specific offer. This article explains the basics and practical steps. Test results apply to their documented scope and date.