Skip to content

Latest commit

 

History

History
executable file
·
270 lines (193 loc) · 10 KB

File metadata and controls

executable file
·
270 lines (193 loc) · 10 KB
id 23a2a8
name Image has non-empty accessible name
rule_type atomic
description This rule checks that each image either has a non-empty accessible name or is marked up as decorative.
accessibility_requirements
wcag20:1.1.1 wcag-technique:G94 wcag-technique:G95
forConformance failed passed inapplicable
true
not satisfied
further testing needed
further testing needed
forConformance failed passed inapplicable
false
not satisfied
further testing needed
further testing needed
forConformance failed passed inapplicable
false
not satisfied
further testing needed
further testing needed
input_aspects
Accessibility Tree
DOM Tree
CSS Styling
acknowledgments
authors previous_authors funding
Wilco Fiers
Anne Thyme Nørregaard
Stein Erik Skotkjerra
WAI-Tools
htmlHintIgnore
alt-require

Applicability

This rule applies to HTML img elements and HTML elements that are a semantic img, except if the element is programmatically hidden.

Expectation

Each target element has an accessible name that is not empty (""), or has a semantic role of none or presentation.

Assumptions

There are no assumptions.

Accessibility Support

  • There are several popular browsers that do not treat images with an empty alt attribute (alt="") as having a role of presentation but instead add the img element to the accessibility tree with a semantic role of either img or graphic.
  • Implementation of Presentational Roles Conflict Resolution varies from one browser or assistive technology to another. Depending on this, some semantic img elements can fail this rule with some technology but users of other technologies would not experience any accessibility issue.
  • Images can have their role set to presentation through an empty alt attribute. Presentational Roles Conflict Resolution does not specify what to do if such an image is focusable (it only specifies what to do in case of explicit role="none" or role="presentation"). Some browsers expose these images and some don't. Thus, this rule may fail for technologies that expose these without creating an accessibility issue for users of other technologies.

Background

Bibliography

Test Cases

Passed

Passed Example 1

This img element has an accessible name because of the alt attribute.

<img alt="W3C logo" src="/test-assets/shared/w3c-logo.png" />

Passed Example 2

This semantic img element has an accessible name because of the aria-label attribute.

<div
	role="img"
	aria-label="W3C logo"
	style="width:72px; height:48px; background-image: url(/test-assets/shared/w3c-logo.png)"
></div>

Passed Example 3

This semantic img element has an accessible name because of an aria-labelledby attribute and an element with matching id.

<div style="display: none" id="img-label">W3C logo</div>
<div
	role="img"
	aria-labelledby="img-label"
	style="width:72px; height:48px; background-image: url(/test-assets/shared/w3c-logo.png)"
></div>

Passed Example 4

This img element has an accessible name because of a title attribute.

<img title="W3C logo" src="/test-assets/shared/w3c-logo.png" />

Passed Example 5

This img element has an implicit role of presentation because of the empty alt attribute.

<img alt="" src="/test-assets/shared/background.png" />

Passed Example 6

This img element has an explicit role of presentation because of the value of the role attribute.

<img role="presentation" style="width:72px; height:48px; background-image: url(/test-assets/shared/background.png)" />

Passed Example 7

This img element has an explicit role of none because of the value of the role attribute.

<img role="none" src="/test-assets/shared/background.png" />

Passed Example 8

This off screen img element has an implicit role of presentation because of the empty alt attribute.

<div style="margin-left:-9999px;">
	<img alt="" src="/test-assets/shared/background.png" />
</div>

Failed

Failed Example 1

This img element has an empty accessible name and an implicit role of img because it is missing an alt attribute.

<img src="/test-assets/shared/w3c-logo.png" />

Failed Example 2

This element with role of img has an empty accessible name.

<div role="img" style="width:72px; height:48px; background-image: url(/test-assets/shared/w3c-logo.png)"></div>

Failed Example 3

This img element inside a div positioned off screen has an empty accessible name and an implicit role of img.

<div style="margin-left:-9999px;"><img src="/test-assets/shared/w3c-logo.png" /></div>

Failed Example 4

This img element has an empty accessible name because the space in the alt attribute is trimmed off by the accessible name computation. Because of the space, the alt attribute is not empty ("") which gives the element the implicit role of img.

<img src="/test-assets/shared/w3c-logo.png" alt=" " />

Failed Example 5

This img element has an explicit role of none. However, it is focusable due to the tabindex attribute. Because of this it has a semantic role of img due to Presentational Roles Conflict Resolution. It does not have an accessible name.

<img role="none" tabindex="0" src="/test-assets/shared/w3c-logo.png" />

Inapplicable

Inapplicable Example 1

This svg element has an implicit role of graphics-document.

<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
	<circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
</svg>

Inapplicable Example 2

This semantic img element is hidden with aria-hidden set to "true".

<div
	role="img"
	aria-hidden="true"
	style="width:72px; height:48px; background-image: url(/test-assets/shared/w3c-logo.png)"
></div>

Inapplicable Example 3

This img element is hidden with aria-hidden set to "true".

<img src="/test-assets/shared/w3c-logo.png" aria-hidden="true" />

Inapplicable Example 4

This img element is hidden because its parent has display: none.

<div style="display: none">
	<img src="/test-assets/shared/w3c-logo.png" />
</div>

Inapplicable Example 5

This img element is hidden with visibility: hidden.

<div style="visibility: hidden">
	<img src="/test-assets/shared/w3c-logo.png" />
</div>
Details ## Boundary Examples

These examples are not normative and not require for consistent implementations. They illustrate limitations and boundaries of the rule. Passed and Inapplicable examples in this category are likely to fail the rule's accessibility requirement, showing how the rule is only a partial test. Testing tools and methodologies are encouraged to be more clever than the rule, and to report the correct outcome for these examples. Therefore, they are not required for consistent implementation.

Passed Examples

Passed Example 1

This img element has a non-empty accessible name. The name is not descriptive and therefore the image fails [Success Criterion 1.1.1 Non-text content][sc111], but this rule only check for existence of a name. This img also fails rule Image accessible name is descriptive.

<img alt="Neil Armstrong walking on the Moon" src="/test-assets/shared/w3c-logo.png" />