| 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 |
|
||||||||||||||||||||||||||||||
| input_aspects |
|
||||||||||||||||||||||||||||||
| acknowledgments |
|
||||||||||||||||||||||||||||||
| htmlHintIgnore |
|
This rule applies to HTML img elements and HTML elements that are a semantic img, except if the element is programmatically hidden.
Each target element has an accessible name that is not empty (""), or has a semantic role of none or presentation.
There are no assumptions.
- There are several popular browsers that do not treat images with an empty
altattribute (alt="") as having a role ofpresentationbut instead add theimgelement to the accessibility tree with a semantic role of eitherimgorgraphic. - Implementation of Presentational Roles Conflict Resolution varies from one browser or assistive technology to another. Depending on this, some semantic
imgelements 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
presentationthrough an emptyaltattribute. 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 explicitrole="none"orrole="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.
- Understanding Success Criterion 1.1.1: Non-text Content
- G94: Providing short text alternative for non-text content that serves the same purpose and presents the same information as the non-text content
- G95: Providing short text alternatives that provide a brief description of the non-text content
- H37: Using alt attributes on img elements
- ARIA6: Using aria-label to provide labels for objects
- ARIA10: Using aria-labelledby to provide a text alternative for non-text content
- H67: Using null alt text and no title attribute on img elements for images that AT should ignore
- F38: Failure of Success Criterion 1.1.1 due to not marking up decorative images in HTML in a way that allows assistive technology to ignore them
- F65: Failure of Success Criterion 1.1.1 due to omitting the alt attribute or text alternative on img elements, area elements, and input elements of type "image"
This img element has an accessible name because of the alt attribute.
<img alt="W3C logo" src="/test-assets/shared/w3c-logo.png" />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>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>This img element has an accessible name because of a title attribute.
<img title="W3C logo" src="/test-assets/shared/w3c-logo.png" />This img element has an implicit role of presentation because of the empty alt attribute.
<img alt="" src="/test-assets/shared/background.png" />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)" />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" />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>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" />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>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>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=" " />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" />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>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>This img element is hidden with aria-hidden set to "true".
<img src="/test-assets/shared/w3c-logo.png" aria-hidden="true" />This img element is hidden because its parent has display: none.
<div style="display: none">
<img src="/test-assets/shared/w3c-logo.png" />
</div>This img element is hidden with visibility: hidden.
<div style="visibility: hidden">
<img src="/test-assets/shared/w3c-logo.png" />
</div>Details
## Boundary ExamplesThese 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.
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" />