Description
Product
axe Extension
Product Version
4.60.1
Latest Version
- I have tested the issue with the latest version of the product
Issue Description
Expectation
IDs used in ARIA and labels must be unique rule uses misleading language.
Rule ID: duplicate-id-aria
Ruleset: axe-core 4.7
User Impact: Critical
Guidelines: WCAG 2.1 (A), WCAG 2.0 (A)
Actual
The name of this rule states that IDs in ARIA or labels must be unique. However, the issue is actually that the ID the for
attribute is referencing is not unique.
The duplication itself does not sit in the <label>
element. This distinction is important as it is possible to have multiple label elements for a single input and each of those would correctly have the same for
attribute ID. In this scenario, this rule would be confusing, making users think the duplicated for
attribute values are the problem.
Additionally, for the example below, the extension provides the following advice:
To solve this problem, you need to fix the following: Document has multiple elements referenced with ARIA with the same id attribute: search
Related Node:
<form id="search" action="/" method="get">
This description of how to fix the issue is not helpful. It only mentions the ARIA part of the rule which, in this case, does not apply.
How to Reproduce
Issue was picked up due to two identical search inputs on a website:
<form id="search" action="/" method="get">
<label class="visually-hidden" for="search">Search term:</label>
<div class="search-field">
<input type="text" name="s" id="searchInput" autocomplete="off" value="" placeholder="Search">
<button type="submit">Search</button>
</div>
</form>
<form id="search" action="/" method="get">
<label class="visually-hidden" for="search">Search term:</label>
<div class="search-field">
<input type="text" name="s" id="searchInput" autocomplete="off" value="" placeholder="Search">
<button type="submit">Search</button>
</div>
</form>
(The duplicate IDs on the input elements in this example are flagged by the extension separately under IDs of active elements must be unique)