Accessibility Insights

Back to Info and Examples for Accessibility Insights for Web

aria-required-parent

Certain ARIA roles must be contained by particular parent elements.

Why it matters

An ARIA role attribute can be added to an element to instruct assistive technologies to treat the element as something other than its native HTML element type. For example, an <li> element with role="option" is to be treated as a selectable option in a listbox control, not as a static list item.

Some ARIA "child" roles identify managed controls that are always part of a larger composite control, identified by a "parent" role. For example, role="option" identifies a child control that is managed by a parent control identified by role="listbox". People who use assistive technologies might find it difficult or impossible to use a child control if its managing control lacks the required parent role.

How to fix

  1. Identify the ARIA role that best identifies the element’s function.
  2. In the Chrome or Edge accessibility pane, examine the elements serving as the managed controls to verify they have the correct "child" role attributes.
  3. Identify (or add) the element serving as the managing control and add the appropriate "parent" role to it.
  4. Apply any ARIA state and property attributes that are required for the given roles.
  5. Make sure the value of each ARIA property attribute is correct.
  6. Make sure the value of each ARIA state attribute updates as needed to reflect the element’s current state.

For details about composite widgets and their required roles, see WAI-ARIA Authoring Practices 1.1: Design Patterns and Widgets.

Example

 

Fail

This code functions together as a menu (composite) control. The managed <a> elements have the correct "child" roles ( menuitem ), but the managing <ul> element is missing the required "parent" role ( menu or menubar ). Because assistive technologies can’t identify this code as a menu, some users don’t know how to interact with it.

<ul id="myaccount">
<li>
<a role="menuitem" href="#" tabindex="0">Profile</a>
<li>
<a role="menuitem" href="#" tabindex="0">Preferences </a>
</li>
</ul>
 

Pass

The parent of the menuitem children is marked with role="menu". Assistive technologies can inform users that the managing control is a menu. In addition, the menu has been given an accessible name by adding an aria-label attribute to the parent element.

<ul id="myaccount" role="menu" aria-label="My Account">
<li>
<a role="menuitem" href="#" tabindex="0">Profile</a>
<li>
<a role="menuitem" href="#" tabindex="0">Preferences </a>
</li>
</ul>

About this rule

This rule passes if:

  • Required ARIA parent is present

More examples