Users of screen readers and other assistive technologies need information about the behavior and purpose of controls on your web page. Native HTML controls like buttons and radio groups come with that information built in. For custom controls you create, however, you must provide the information with ARIA roles and attributes. (Learn more in the Introduction to ARIA.)
How Lighthouse identifies ARIA inputs without accessible names
Lighthouse flags custom ARIA input fields whose names aren't accessible to assistive technologies:
Elements that have any of the following ARIA roles but don't have accessible names will cause this audit to fail:
This audit is similar to the Not all ARIA toggle fields have accessible names audit but checks a different set of ARIA roles.
Caution: Most common input types can be created with native HTML elements, which come with built-in behaviors and accessible semantics that can be time consuming to replicate. Consider using native elements instead of ARIA roles if possible.
The Lighthouse Accessibility score is a weighted average of all the accessibility audits. See the Lighthouse accessibility scoring post for more information.
How to add accessible names to your custom ARIA input fields
The easiest way to provide an accessible name for most elements is to include text content in the element. However, custom input fields typically don't have inner text, so you can use one of two strategies instead.
Option 1: Add an
aria-label attribute to the element
aria-label attribute to define the name for the current element.
For example, this custom combobox will be announced as "country" to assistive technology users:
<div id="combo1" aria-label="country" role="combobox">England</div>
Option 2: Refer to another element using
aria-labelledby attribute to identify another element, using its ID,
to serve as the name for the current element.
For example, this custom searchbox refers to the
as its label and will be announced as "Search currency pairs":
<p id="searchLabel">Search currency pairs:</p>
- Source code for Not all ARIA input fields have accessible names audit
- ARIA input fields have an accessible name (Deque University)
- Labels and text alternatives
- Use semantic HTML for easy keyboard wins