Skip to main content
In tritt das BFSG in Kraft - Ist Deine Website schon fit?Jetzt Website prüfen
Dieser Inhalt ist derzeit nur auf Englisch verfügbar

Audit aria-valid-attr-value

Ensure all ARIA attributes have valid values

Impact:

Critical

WCAG-Konformität:

  • A
    WCAG 4.1.2

Issue types:

failure, needs review

ARIA state or property has valid value

This rule checks that each ARIA state or property has a valid value type.

Applicability

This rule applies to any WAI-ARIA state or property that has a non-empty ("") attribute value, and that is specified on an HTML or SVG element.

Expectation

Each test target has an attribute value that is valid according to its WAI-ARIA value type.

Exception: For value types ID Reference and ID Reference List no ID referenced elements are required.

Background

Using invalid ARIA attribute values is often the result of a typo or other developer error. These attributes are then either ignored, or a default value is assumed by browsers and assistive technologies. This often means that a state or property which should exist is missing or has an unexpected value. If the default value for invalid attribute values happens to match the author's intention for the value, there will not be an accessibility issue.

This rule does not require the target of an ID Reference to exist. This is because referencing an element that does not exist, and not having the reference at all has the same end result. A common use case for using ID Reference for a non-existing ID is to use a static aria-errormessage on an input element, and to only insert the element with the error message if there is an actual error. There are some cases in which ID references are required. These are tested in a separate rule.

Assumptions

There are no assumptions.

Accessibility Support

Some user agents treat the value of aria-* attribute as case-sensitive (even when these are not ID) while some treat them as case-insensitive.

Related rules

Bibliography

Test Cases

Passed

Passed Example 1

The aria-label attribute value of Family name is allowed for the string value type.

<div role="textbox" aria-label="Family name"></div>

Passed Example 2

The aria-required attribute value of true is allowed for the true/false value type.

<div role="textbox" aria-required="true" aria-label="Family name"></div>

Passed Example 3

The aria-expanded attribute value of undefined is allowed for the true/false/undefined value type.

<div role="button" aria-expanded="undefined">A button</div>

Passed Example 4

The aria-pressed attribute value of mixed is allowed for the tristate value type.

<div role="button" aria-pressed="mixed">Partially pressed button</div>

Passed Example 5

The aria-errormessage attribute value is an ID Reference value type. The presence of an element with a matching ID is not required by this rule.

<div role="textbox" aria-errormessage="my-error" aria-label="A textbox"></div>

Passed Example 6

The aria-owns attribute value is a valid ID Reference List value type. Both tokens reference elements that exist in the same [DOM tree][].

<h1>Shopping list</h1>
<div role="list" aria-owns="item1 item2"></div>
<div id="item1">Apples</div>
<div id="item2">Bananas</div>

Passed Example 7

The aria-rowindex attribute value of 2 is a valid integer value type.

<div role="gridcell" aria-rowindex="2">Fred</div>

Passed Example 8

The aria-valuemin, aria-valuemax and aria-valuenow attribute values are valid for a number value type.

<div role="spinbutton" aria-valuemin="1.0" aria-valuemax="2.0" aria-valuenow="1.5" aria-label="Select a value"></div>

Passed Example 9

The aria-current attribute value of page is a valid token value type.

<a href="/" aria-current="page">Home</a>

Passed Example 10

The aria-relevant attribute value has a text and removals tokens. Both are valid tokens for a aria-relevant token list value type.

<div role="alert" aria-relevant="text removals"></div>

Failed

Failed Example 1

The aria-required attribute value of undefined is not valid for a true/false value type.

<div role="textbox" aria-required="undefined" aria-label="A required textbox"></div>

Failed Example 2

The aria-expanded attribute value of collapsed is not valid for a true/false/undefined value type.

<div role="button" aria-expanded="collapsed">A button</div>

Failed Example 3

The aria-pressed attribute value of horizontal is not valid for a tristate value type.

<div role="button" aria-pressed="horizontal">An other button</div>

Failed Example 4

The aria-rowindex attribute value of 2.5 is not valid for an integer value type because it is a decimal number.

<div role="gridcell" aria-rowindex="2.5">Fred</div>

Failed Example 5

The aria-valuemin, aria-valuemax and aria-valuenow attribute values are strings. These should all be of the number value type instead.

<div role="spinbutton" aria-valuemin="one" aria-valuemax="three" aria-valuenow="two" aria-label="Choose a value"></div>

Failed Example 6

The aria-live attribute value of page is not a valid token, because page is not a token for aria-live.

<div role="main" aria-live="page"></div>

Failed Example 7

The aria-relevant attribute value has the two tokens text and always. The always token is not valid for the aria-relevant token list. In order to be a valid value, all tokens must be valid.

<div role="alert" aria-relevant="text always"></div>

Inapplicable

Inapplicable Example 1

Element does not have any ARIA states or properties

<div>Some Content</div>

Inapplicable Example 2

Element has ARIA role, but no ARIA states or properties

<div role="button">Some Content</div>

Inapplicable Example 3

The aria-live attribute does not have a value.

<div role="alert" aria-live>Remember to be awesome!</div>

Inapplicable Example 4

The aria-hidden attribute is not on an HTML or SVG element.

<math aria-hidden="false"></math>

Autoren: Anne Thyme Nørregaard, Wilco Fiers

Finanzierung: WAI-Tools