Require a consistent role for presentational elements

Rule ID:
presentation-role-style
Category:
Style
Standards:
-
Fixable:
Yes

ARIA 1.1 introduces the role none as a synonym for the presentation role. Many authors confused role="presentation" with aria-hidden="true", and role="none" conveys the intended meaning more clearly.

This rule requires one of the two synonyms to be used consistently. By default role="none" is preferred.

Compatibility

role="none" was introduced in ARIA 1.1 and very old browsers such as Internet Explorer does not support it. If you target ARIA 1.0 or need to support very old browsers, configure this rule to prefer role="presentation".

Rule details

Examples of incorrect code for this rule:

<img role="presentation" />
error: Prefer to use role="none" instead of role="presentation" (presentation-role-style)
> 1 | <img role="presentation" />
    |            ^^^^^^^^^^^^


1 error found.
1 error potentially fixable with the `--fix` option.

Examples of correct code for this rule:

<img role="none" />

Options

This rule takes an optional object:

{
  "prefer": "none"
}

prefer

Sets the prefered role to use.

See also

Version history