# Use ARIA when necessary

- Check 11.10 · Semantic HTML and accessibility · Important
- Source: https://checklist-seo-geo.com/en/semantic-html-accessibility/use-aria-when-necessary
- Use ARIA only when native HTML falls short: menus, tabs, dynamic messages, current page. Templates for WordPress, Shopify, Laravel and Next.js.
- Updated on 2026-11-25
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/semantic-html-accessibility/use-aria-when-necessary.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

ARIA (Accessible Rich Internet Applications) is a set of attributes (`role`, `aria-expanded`, `aria-label`, `aria-live`…) that tell assistive technologies what HTML alone does not say: whether a menu is open or closed, which page is the current one, a message that has just appeared. The rule is to use the native HTML element first, and ARIA only to fill a gap. Once the task is done, interactive components expose an accurate role, name and state, and no ARIA attribute contradicts the HTML.

## Why it matters

From the DOM, the browser builds an accessibility tree: for each element, a role (button, link, checkbox), a name and states. Screen readers, voice control and some automation tools read this tree, not the rendered page. A `<button>` appears in it as a button, focusable and operable from the keyboard, with nothing to add. A clickable `<div>` only appears as a block of text.

ARIA changes this tree, and nothing else. `role="button"` on a `<div>` announces a button, but makes it neither focusable nor operable with Enter or Space: the developer has to program all of that. The W3C sums up the stakes in its ARIA Authoring Practices Guide (APG): a role is a promise that the code must keep. Its “Using ARIA” note sets out the first rule: if a native HTML element or attribute already does the job, use it.

Misused ARIA does more harm than no ARIA at all. The 2026 [WebAIM Million](https://webaim.org/projects/million/) study found an average of 59.1 detected errors on home pages that use ARIA, against 42 on those that do not. This is a correlation, not proof of cause, but it illustrates the risk of ARIA added by reflex.

On the AI side, browsing agents rely on the accessibility tree to find buttons, menus and their state; Microsoft's Playwright MCP server, for example, works on snapshots of this tree rather than on screenshots. A correct `aria-expanded` tells them that a menu is open. No search engine documents any effect of ARIA on rankings.

## What it improves

- **Accessibility**: WCAG success criteria 4.1.2 “Name, Role, Value” and 4.1.3 “Status Messages”.
- **AI agents**: roles and states usable by agents that read the accessibility tree. See [make component states accessible](https://checklist-seo-geo.com/en/ai-agent-compatibility/make-component-states-accessible).
- **Code quality**: fewer reinvented components, less JavaScript to maintain when the native element replaces a `<div>` dressed up with ARIA.
- **Rankings**: no documented direct effect.

## How to check

**Automated audit.** axe DevTools and Lighthouse check that ARIA is valid: unknown attributes (`aria-valid-attr`), invalid values (`aria-valid-attr-value`), missing required attributes (`aria-required-attr`), attributes not allowed on a role (`aria-allowed-attr`, `aria-prohibited-attr`), hidden focusable elements (`aria-hidden-focus`). WAVE shows the ARIA attributes present in its dedicated category, so you can review them.

**Search the code.** Find the fake controls:

```bash
grep -rn -E 'role="(button|link|checkbox|tab|menu|menuitem)"' resources/ templates/ src/ --include=*.{html,php,twig,liquid,tsx,jsx,vue}
```

Every `role="button"` on anything other than a `<button>` must be justified or replaced.

**Accessibility tree.** In Chrome, Elements panel, Accessibility tab, check “Enable full-page accessibility tree”: verify the role, name and states of each interactive component, then open and close the menu to see `expanded` change.

**Screen reader.** A five-minute test with NVDA (Windows, free) or VoiceOver (macOS and iOS, built in): move through the page with Tab, open the menu, submit a form. What you hear must match what you see.

## How to implement

### Before you start

First replace whatever exists in native HTML:

| Need | Native HTML to prefer | ARIA, only if native does not fit |
| --- | --- | --- |
| Action | `<button type="button">` | `role="button"`, `tabindex="0"`, handling of Enter and Space |
| Navigation | `<a href>` | None |
| Collapsible block | `<details>` and `<summary>` | Button with `aria-expanded` and `aria-controls` |
| Modal window | `<dialog>` opened by `showModal()` | `role="dialog"`, `aria-modal`, focus management |
| Tooltip or panel | `popover` attribute | `role="tooltip"`, `aria-describedby` |
| Navigation region | `<nav>` | `role="navigation"` |
| Main content | `<main>` | `role="main"` |
| Checkbox, switch | `<input type="checkbox">` | `role="switch"` and `aria-checked` |

The uses of ARIA that remain legitimate, and common:

| Attribute | Use |
| --- | --- |
| `aria-expanded` | Open or closed state of a button that shows a menu or a panel |
| `aria-controls` | Ties that button to the element it controls |
| `aria-current="page"` | Link to the current page in a menu or a breadcrumb |
| `aria-label` on `<nav>` | Tells several navigation regions apart (“Main navigation”, “Breadcrumb”) |
| `aria-describedby` | Ties help text or an error message to a field |
| `aria-invalid="true"` | Field in error |
| `role="status"` or `aria-live="polite"` | Announces a message without moving focus (“Product added to cart”) |
| `role="alert"` | Urgent message, announced immediately |
| `aria-hidden="true"` | Decorative icon next to text |
| `aria-label` on an icon button | Gives a name to a button with no visible text |

For complex components (tabs, combobox, tree view, carousel), follow the matching pattern in the [W3C ARIA patterns guide](https://www.w3.org/WAI/ARIA/apg/patterns/): it specifies the roles, attributes and expected keyboard keys.

Collapsible menu template, ready to paste:

```html
<nav aria-label="Main navigation">
  <button type="button" class="menu-toggle" aria-expanded="false" aria-controls="menu-principal">
    <svg aria-hidden="true" focusable="false" width="20" height="20"><use href="#icone-menu"></use></svg>
    Menu
  </button>
  <ul id="menu-principal" hidden>
    <li><a href="/" aria-current="page">Home</a></li>
    <li><a href="/services">Services</a></li>
    <li><a href="/contact">Contact</a></li>
  </ul>
</nav>

<script>
  document.querySelectorAll('.menu-toggle').forEach((bouton) => {
    const menu = document.getElementById(bouton.getAttribute('aria-controls'));

    bouton.addEventListener('click', () => {
      const ouvert = bouton.getAttribute('aria-expanded') === 'true';
      bouton.setAttribute('aria-expanded', String(!ouvert));
      menu.hidden = ouvert;
    });
  });
</script>
```

Announcement region: it must exist in the page **before** the message is inserted into it, otherwise some screen readers do not announce it.

```html
<p id="annonce-panier" role="status"></p>

<script>
  function annoncerAjout(nomProduit) {
    document.getElementById('annonce-panier').textContent = `${nomProduit} has been added to the cart.`;
  }
</script>
```

Icon button:

```html
<button type="button" aria-label="Close the window">
  <svg aria-hidden="true" focusable="false" width="16" height="16"><use href="#icone-croix"></use></svg>
</button>
```

### WordPress

Versions: WordPress 6.4 and later (checked up to 7.1).

- **Site Editor**: the Navigation block produces a `<nav>` and handles `aria-expanded` on its submenus and its mobile button. Prefer it to plugin mega menus, which have to be tested one by one with the keyboard and a screen reader.
- **Classic themes**: since WordPress 5.1, `wp_nav_menu()` itself adds `aria-current="page"` to the current page link, in addition to the `current-menu-item` class. Check that a custom walker in the theme does not remove it; if it does, restore it with a filter in the child theme's `functions.php`:

```php
add_filter('nav_menu_link_attributes', function (array $atts, WP_Post $item): array {
    if ($item->current) {
        $atts['aria-current'] = 'page';
    }

    return $atts;
}, 10, 2);
```

- **Page builders**: Elementor, Divi and the like often offer a custom attributes field in the element's advanced settings. Do not use it to turn a container into a button: use the Button widget or a real link.
- **Custom HTML block**: for a standalone component, paste the collapsible menu template above.

### Shopify

Versions: Online Store 2.0 themes (Dawn and its derivatives), November 2026.

Recent themes such as Dawn use `<details>` and `<summary>` for menus and filters, which avoids much of the ARIA. In your own sections, mark the current page with the `current` property of menu links:

```liquid
<nav aria-label="Main navigation">
  <ul>
    {% for link in linklists.main-menu.links %}
      <li>
        <a href="{{ link.url }}"{% if link.current %} aria-current="page"{% endif %}>{{ link.title }}</a>
      </li>
    {% endfor %}
  </ul>
</nav>
```

For AJAX add-to-cart, add a `role="status"` region in `layout/theme.liquid` and fill it from the theme script. Third-party apps (reviews, filters, signup pop-ups) inject their own markup: test them with axe DevTools after installing them.

### Laravel

Versions: Laravel 10 to 13, Alpine.js 3, Livewire 3 and 4.

With Blade and Alpine.js, bind the ARIA state to the same variable as the display:

```blade
<nav aria-label="Main navigation" x-data="{ open: false }">
    <button type="button" aria-controls="menu-principal" x-bind:aria-expanded="open.toString()" x-on:click="open = ! open">
        Menu
    </button>
    <ul id="menu-principal" x-show="open" x-cloak>
        <li><a href="{{ route('home') }}" @if(request()->routeIs('home')) aria-current="page" @endif>Home</a></li>
        <li><a href="{{ route('services.index') }}" @if(request()->routeIs('services.*')) aria-current="page" @endif>Services</a></li>
    </ul>
</nav>
```

With Livewire, place the `role="status"` region outside the part replaced by the component, or in an element that is not recreated on every render, so that it exists before the message.

### Next.js

Versions: Next.js 15 and 16 (App Router).

In JSX, ARIA attributes keep their hyphenated names (`aria-expanded`), unlike other attributes, which switch to camelCase. The `Link` component does not add `aria-current`: compute it with `usePathname()`.

```tsx
'use client';

import Link from 'next/link';
import { usePathname } from 'next/navigation';

const liens = [
  { href: '/', label: 'Home' },
  { href: '/services', label: 'Services' },
];

export function Menu() {
  const pathname = usePathname();

  return (
    <nav aria-label="Main navigation">
      <ul>
        {liens.map((lien) => (
          <li key={lien.href}>
            <Link href={lien.href} aria-current={pathname === lien.href ? 'page' : undefined}>
              {lien.label}
            </Link>
          </li>
        ))}
      </ul>
    </nav>
  );
}
```

The Next.js ESLint configuration (`eslint-config-next`, declared in `eslint.config.mjs` and run with `npx eslint .` since Next.js 16 removed `next lint`) includes `eslint-plugin-jsx-a11y`, which flags ARIA attributes that are unknown or incompatible with the role. Accessible component libraries (React Aria, Radix UI, Headless UI) handle ARIA and the keyboard for complex components: prefer them to a home-grown implementation.

### Nuxt

Versions: Nuxt 3 and 4 (Vue Router 4); Angular 14 and later for `ariaCurrentWhenActive`.

Vue Router and `<NuxtLink>` add `aria-current="page"` to the link that exactly matches the active route, with no code. For states, bind the attribute to the reactive data: `<button :aria-expanded="ouvert" aria-controls="menu-principal">`. In Angular, `routerLinkActive` accepts `ariaCurrentWhenActive="page"`, and ARIA attributes are bound with `[attr.aria-expanded]`.

## Common mistakes

- **`role="menu"` on the site navigation**: this role denotes an application menu (like “File, Edit”) and requires arrow-key navigation. Site navigation is a `<nav>` containing a list of links.
- **`<div role="button">` without keyboard support**: the screen reader announces a button that cannot be reached with Tab or activated with Enter.
- **`aria-hidden="true"` on a focusable element** or on a parent of links: the element receives focus but nothing announces it.
- **`aria-label` on a `<div>` or a `<span>` with no role**: ARIA prohibits naming these generic elements, and screen readers often ignore it.
- **Frozen state**: `aria-expanded="false"` written in the HTML and never updated by the script.
- **Redundant role**: `<button role="button">`, `<nav role="navigation">`. Harmless, but useless.
- **`aria-live` region created at the same time as its message**: the announcement is lost.
- **Hiding text from bots or stuffing keywords into `aria-label`**: no documented effect on rankings, and harmful for screen reader users.

## Frequently asked questions

### Do ARIA attributes improve SEO?

No search engine documents any effect of ARIA attributes on rankings. ARIA serves assistive technologies and, increasingly, AI agents that read the accessibility tree to understand buttons, menus and their state. Adding keywords to an aria-label does nothing for SEO and degrades the experience of screen reader users.

### Should role="navigation" be added to the nav tag?

No, the nav element already carries the navigation role in the accessibility tree, just as main carries the main role and button the button role. Repeating the role is useless, though not harmful. However, when a page contains several nav elements, for example the main menu and the breadcrumb, give each one a distinct aria-label so that screen readers can tell them apart.

### When is ARIA really necessary?

ARIA is necessary when native HTML cannot express a state or a relationship: the open or closed state of a menu button with aria-expanded, the current page with aria-current, a dynamic message with role status, an icon button with no text with aria-label, or a complex component such as tabs. For everything else, a native HTML element does better, with keyboard support included.

### Is a div with role="button" as good as a button?

No, role button only announces a button to assistive technologies. The div does not become focusable with Tab, does not respond to the Enter and Space keys and cannot be disabled: everything has to be programmed with tabindex and event handlers. A native button element provides all of this with no code. Reserve role button for cases where the markup cannot be changed.

## Resources

- [W3C: Using ARIA (rules of use)](https://www.w3.org/TR/using-aria/)
- [W3C: ARIA Authoring Practices Guide (APG)](https://www.w3.org/WAI/ARIA/apg/)
- [W3C: ARIA in HTML (implicit roles and allowed attributes)](https://www.w3.org/TR/html-aria/)
- [MDN: ARIA](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA)
- [Chrome for Developers: Accessibility features reference for DevTools](https://developer.chrome.com/docs/devtools/accessibility/reference)
- [Next.js: Accessibility](https://nextjs.org/docs/architecture/accessibility)
- [WebAIM Million](https://webaim.org/projects/million/)

Next steps: [test keyboard navigation](https://checklist-seo-geo.com/en/semantic-html-accessibility/test-keyboard-navigation), [make component states accessible](https://checklist-seo-geo.com/en/ai-agent-compatibility/make-component-states-accessible) and [test with axe, WAVE or Lighthouse](https://checklist-seo-geo.com/en/semantic-html-accessibility/test-axe-wave-lighthouse).
