Skip to main content

no-contradictory-aria-prop

Warns when an ARIA property's value contradicts the current or implicit value of an equivalent native HTML attribute, per ARIA in HTML §4.2: native HTML attributes must take precedence over their ARIA equivalents.

When the element has a Boolean native attribute (required, disabled, readonly, checked), only aria-*="false" contradicts it. aria-colspan and aria-rowspan contradict colspan and rowspan when the values differ, compared as the value type of the native attribute reads them: a number as a number, a keyword ASCII case-insensitively, and any other value as written.

aria-placeholder, aria-valuemax and aria-valuemin are reported beside placeholder, max and min whatever the value is, the same value included:

Authors MUST NOT use the aria-placeholder attribute on any element which also has a placeholder attribute.

Cite: ARIA in HTML §4.2 Requirements for use of ARIA attributes in place of equivalent HTML attributes

aria-readonly="true" on an element that is editable (by its own contenteditable or by the closest ancestor that has one) is reported too:

Authors MUST NOT set aria-readonly="true" on an element that has isContentEditable="true".

Cite: ARIA in HTML §4.2 Requirements for use of ARIA attributes in place of equivalent HTML attributes

When the element lacks the native attribute, an author may use aria-required, aria-disabled and aria-readonly in place of required, disabled and readonly, so <input type="text" aria-required="true"> is not reported. aria-checked is the exception: on an element that allows checked, aria-checked="true" without checked is reported as contradicting the implicit checked, because the checkedness of the element can be in opposition to it:

Authors MAY use the aria-required attribute on any element that is allowed the required attribute in HTML, or any element with a WAI-ARIA role which allows the aria-required attribute.

Cite: ARIA in HTML §4.2 Requirements for use of ARIA attributes in place of equivalent HTML attributes

Authors MUST NOT use the aria-checked attribute on any element where the checkedness, or the indeterminate checked value of the element can be in opposition to the current value of the aria-checked attribute.

Cite: ARIA in HTML §4.2 Requirements for use of ARIA attributes in place of equivalent HTML attributes

The names of ARIA attributes are compared as no-unknown-attr compares names (see its "Attribute name case" section): ARIA-LABEL is the same attribute as aria-label where the DOM treats attribute names as case-insensitive, such as on an HTML element, and a different one where it does not, such as on an <svg> element in JSX.

Split out of the former wai-aria-implicit-props rule, alongside no-redundant-aria-prop. This half is must-level (error); the redundant half stays should-level (warning).

❌ Examples of incorrect code for this rule

<input type="checkbox" checked aria-checked="false" />
<input type="checkbox" aria-checked="true" />

✅ Examples of correct code for this rule

<input type="checkbox" checked />
<input type="text" aria-required="true" />

Interface​

{
"no-contradictory-aria-prop": boolean
}

Default Severity​

error