Skip to content

Latest commit

 

History

History
52 lines (34 loc) · 1.12 KB

img-has-name.md

File metadata and controls

52 lines (34 loc) · 1.12 KB

img-has-name

The img element or img role MUST has name.

All non-text content that is presented to the user has a text alternative that serves the equivalent purpose

WCAG 2.1 - 1.1.1: Non-text Content

Options

ignore: string | string[]

Default: None

Ignores the element specified in the selector string from the validation target.

✅ Correct

<img src="https://placebear.com/350/250" alt="bear" />

<svg role="img" aria-label="bear"></svg>

If the element is not exposed to the accessibility API, name allows an empty.

<div aria-hidden="true">
  <img src="https://placebear.com/350/250" />
</div>

Example: ignore: '[data-testid="img"]'

Some img element can be ignored by specifying the ignore option.

<img src="https://placebear.com/350/250" data-testid="img" />

⚠️ Incorrect

<img src="https://placebear.com/350/250" />
<div
  role="img"
  style="background: url(https://placebear.com/350/250); width: 350px; height: 250px;"
></div>