aria-conditional-attr
Use browsers to store the state of a checkbox. Also, do not use attributes that are exclusive to an element in other elements.
Description
This rule covers the following accessibility issues:
-
Browsers use a native state (true, false, mixed) for all checkboxes on a webpage. Screen readers and other assistive technologies perform inconsistently if the
aria-checked
attribute is used while defining checkboxes. This happens when the native state of browsers and the state inaria-checked
doesn’t match. -
The attributes
aria-level
,aria-setsize
,aria-posinset
, andaria-expanded
are exclusively designed for thetreegrid
element. Screen readers and other assistive technologies perform inconsistently if a webpage uses these attributes on other elements.
Success criteria
For this accessibility check to pass, your website must adhere to the following rules:
In checkboxes | In elements other than treegrid
|
---|---|
Do not use the aria-checked attribute. |
Do not use <tr> elements aria-level , aria-setsize , aria-posinset , and aria-expanded . |
Example
In the following example, the aria-checked
attribute is used in a checkbox. This breaks the aria-conditional-attr
rule.
In contrast, the following code snippet doesn’t use the aria-checked
attribute in the checkbox element. Hence, it doesn’t break the aria-conditional-attr
rule.
Consider the following example in which the attributes aria-level
, aria-setsize
, aria-posinset
, and aria-expanded
are used in a grid
element. This code snippet breaks the aria-conditional-attr
rule as these attributes must be used only on treegrid
elements.
In contrast, the following code snippet uses the attributes aria-level
, aria-setsize
, aria-posinset
, and aria-expanded
in a treegrid
element. Hence, this code snippet does not break the aria-conditional-attr
rule.
How to fix?
You can follow these steps to fix issues if this rule gets flagged:
-
Check if the
aria-checked
attribute is used in checkboxes. If so, remove thearia-checked
attribute or use a different element. -
Check if the attributes
aria-level
,aria-setsize
,aria-posinset
, andaria-expanded
are used in an element other thantreegrid
. If so, either modify the element totreegrid
or remove the aria attributes.
Reference
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!