Home / Fix guides / Accessibility (WCAG)

How to fix invalid ARIA attribute values

Invalid ARIA means an accessibility attribute in your page code is misspelled, has a value that does not exist, or does not fit the element. Find the element with a free checker, correct or remove the attribute (native HTML is often the better fix), then re-run the check.

ARIA is a set of extra HTML attributes, such as role and aria-label, that tell screen readers what an element is and what state it is in. An invalid ARIA attribute is one that is misspelled, has a value that does not exist, or does not belong on that element. Browsers show no error, so the page looks fine while people using assistive technology get wrong or missing information.

What the problem looks like

Sighted visitors see nothing. The damage is in the code. Typical examples:

  • A misspelled attribute, such as aria-lable instead of aria-label. It simply does nothing.
  • A wrong value, such as aria-expanded="open" or aria-hidden="yes". These attributes accept true or false.
  • A reference to an ID that does not exist, such as aria-labelledby="title" when nothing on the page has id="title".
  • An invented role, such as role="btn" instead of role="button".
  • A missing required attribute, such as role="checkbox" without aria-checked, or role="heading" without aria-level.
  • A role in the wrong place, such as role="listitem" that is not inside an element with role="list".
  • An attribute the role does not support, such as aria-checked on a plain link.

Why it matters

Screen reader users depend on ARIA for names, roles and states. A broken value can make a menu button announce nothing useful, or a form field read out with no label, so the visitor cannot tell what to press or fill in. That is a failure of WCAG 2.2 success criterion 4.1.2 Name, Role, Value, which is Level A, the most basic level.

For a business, the practical result is customers who cannot finish a checkout or contact form, and possible trouble with clients, tenders or regulations that require accessible sites. Invalid ARIA is also a sign that a theme, plugin or custom script was not tested with assistive technology.

How to check your site for free

  • Lighthouse in Chrome: open DevTools, choose the Lighthouse tab, tick Accessibility and run it. Look for items about ARIA attributes being valid and not misspelled, having valid values, and ARIA roles being valid.
  • axe DevTools (free browser extension from Deque): look for the rules aria-valid-attr, aria-valid-attr-value, aria-roles and aria-required-attr.
  • WAVE (free extension from WebAIM): shows ARIA items on the page itself.
  • W3C Nu HTML Checker at validator.w3.org/nu: also reports bad ARIA in your HTML.

These tools test one page at a time, so check the home page, a product or service page, the contact page, the checkout and any page with menus, tabs, accordions or pop-ups. Week 7 of SiteMonday is a WCAG 2.2 accessibility audit that detects this problem and lists it in a ranked fix list. Finding and explaining is what it does; the fixing is up to you or your developer.

How to fix it

  1. Find the exact element. Each tool shows the HTML snippet or a selector. Note which page and which part of the page it is on.
  2. Ask whether ARIA is needed at all. The first rule of ARIA is to use native HTML when it can do the job. A real <button> already has the button role. Removing a bad role or aria-* attribute is often the right fix.
  3. Correct the spelling or value. Use only values the specification allows. For example, aria-expanded takes true or false, and aria-hidden takes true or false.
  4. Fix broken references. For aria-labelledby and aria-describedby, the ID must exist on the same page and be unique.
  5. Add what the role requires. A custom checkbox needs aria-checked, a heading role needs aria-level, and list items need a list around them.
  6. Remove attributes the role does not allow.
  7. Give controls a name. If a button has only an icon, it needs an accessible name. See icon buttons with no label.
<!-- Wrong -->
<div role="btn" aria-expanded="open">Menu</div>

<!-- Better -->
<button aria-expanded="false">Menu</button>

The aria-expanded value must also change to true when the menu opens. That needs a small script, which is why a developer may be needed for custom menus.

Fixing it on common platforms

Where things are depends on your version and theme, so treat these as the usual places to look.

  • WordPress: invalid ARIA usually comes from the theme, a page builder or a plugin (menus, sliders, accordions, popups). Update everything first. If the error remains, work out which one produces it, for example by testing on a staging copy with plugins switched off one at a time, then report it to the author or edit the template in a child theme. See the WordPress guide.
  • Shopify: the code is in your theme files, under Online Store, Themes, Edit code, mostly in sections and snippets. Check for a theme update before editing. See the Shopify guide.
  • Wix: you have limited access to the code. Look for accessibility or label fields in an element's settings, and replace the element if it has a problem you cannot edit.
  • Webflow: check the custom attributes in the element settings panel. Names and values are typed by hand there, so typos are common.
  • Elementor: custom attributes are usually in a widget's Advanced tab (a Pro feature), entered one per line as name|value. Check for typos there.
  • React and Next.js: use hyphenated names such as aria-expanded, and pass booleans like aria-expanded={isOpen}. React logs a warning for unknown ARIA attributes in development, and the linter plugin eslint-plugin-jsx-a11y catches many other mistakes.

How to confirm the fix worked

Re-run the same tool on the same pages and check that the issue is gone. Then test the states that change after a click: open the menu, expand the accordion, open the popup, and run the check again, because some attributes only appear after interaction.

If you can, listen to the page once. NVDA is free on Windows, and VoiceOver is built into Mac and iPhone. You are checking that each control is announced with a sensible name and state.

How to stop it coming back

  • Prefer native HTML elements over custom ones with roles.
  • Run Lighthouse or axe after every theme update, plugin update or new page template.
  • Add eslint-plugin-jsx-a11y if your site is built with React or Next.js.
  • Keep a short list of any custom code on your site, and ask whoever adds new code to test it with an accessibility checker.
  • Recheck key pages on a regular schedule, since content and plugins change over time.

Step by step for your platform

Questions

Does invalid ARIA change how my site looks?

No. It only affects what assistive technology such as screen readers announces, so the page can look perfect and still be broken for some visitors.

What are the valid values for aria-expanded?

Only `true` or `false` (and the attribute should be left off elements that are not expandable). Values like `open`, `yes` or `1` are invalid.

Is it safe to just delete the ARIA attribute?

Often yes, if the element is a native one such as a button or link, because it already has the right role. For custom widgets built from divs, removing ARIA can make things worse, so ask a developer.

Is no ARIA better than bad ARIA?

Usually, yes. Wrong ARIA can announce misleading information, while plain native HTML is announced correctly by default.

Can an accessibility widget or overlay fix this for me?

Not reliably. Invalid attributes are in your page code, so the dependable fix is to correct them at the source in your theme, plugin or template.

Do I need a developer to fix it?

Not always. Typos in a page builder's custom attributes can be fixed by you, but theme templates, custom menus and scripts that update states usually need a developer.

Related problems