[role]s are contained by their required parent element

Interactive elements are nested inside the correct parent container.

On this page

Impact

ScanGov impact ratings

About

Some ARIA child roles must be contained by specific parent roles to properly perform their intended accessibility functions.

Risks

Screen readers cannot interpret elements outside their required container.

Why it's important

Ensures assistive technologies like screen readers can correctly interpret and announce page elements to users with disabilities.

User stories

As a screen reader user, I want ARIA attributes to be correctly implemented so that I can understand the purpose and state of interactive elements.

Code

Failing pattern:

<!-- Fail: option outside a listbox -->
<li role="option">Alabama</li>

Passing pattern:

<!-- Pass: option inside a listbox -->
<ul role="listbox">
  <li role="option">Alabama</li>
</ul>

Error

ScanGov messaging when a site fails a standard:

Failed: [role]s are contained by their required parent element

Guidance

Indicators

On this page