Skip to content

useAltText (HTML)

biome.json
{
"linter": {
"rules": {
"a11y": {
"useAltText": "error"
}
}
}
}

Enforce that all elements that require alternative text have meaningful information to relay back to the end user.

This is a critical component of accessibility for screen reader users in order for them to understand the content’s purpose on the page. By default, this rule checks for alternative text on the following elements: <img>, <area>, <input type="image">, and <object>.

<img src="image.png" />
code-block.html:1:1 lint/a11y/useAltText ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Provide a text alternative through the alt, aria-label, or aria-labelledby attribute.

> 1 │ <img src="image.png" />
^^^^^^^^^^^^^^^^^^^^^^^
2 │

Meaningful alternative text on elements helps users relying on screen readers to understand content's purpose within a page.

If the content is decorative, redundant, or obscured, consider hiding it from assistive technologies with the aria-hidden attribute.

<input type="image" src="image.png" />
code-block.html:1:1 lint/a11y/useAltText ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Provide a text alternative through the alt, aria-label, or aria-labelledby attribute.

> 1 │ <input type="image" src="image.png" />
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

Meaningful alternative text on elements helps users relying on screen readers to understand content's purpose within a page.

If the content is decorative, redundant, or obscured, consider hiding it from assistive technologies with the aria-hidden attribute.

<area href="foo" />
code-block.html:1:1 lint/a11y/useAltText ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Provide a text alternative through the alt, aria-label, or aria-labelledby attribute.

> 1 │ <area href="foo" />
^^^^^^^^^^^^^^^^^^^
2 │

Meaningful alternative text on elements helps users relying on screen readers to understand content's purpose within a page.

If the content is decorative, redundant, or obscured, consider hiding it from assistive technologies with the aria-hidden attribute.

<object data="foo"></object>
code-block.html:1:1 lint/a11y/useAltText ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Provide a text alternative through the title, aria-label, or aria-labelledby attribute.

> 1 │ <object data="foo"></object>
^^^^^^^^^^^^^^^^^^^
2 │

Meaningful alternative text on elements helps users relying on screen readers to understand content's purpose within a page.

If the content is decorative, redundant, or obscured, consider hiding it from assistive technologies with the aria-hidden attribute.

<img src="image.png" alt="A beautiful landscape" />
<input type="image" src="image.png" alt="Submit" />
<img src="image.png" aria-label="A beautiful landscape" />
<img src="image.png" aria-labelledby="image-description" />
<object data="foo" title="Embedded content"></object>
<!-- Decorative images can be hidden from assistive technologies -->
<img src="decorative.png" alt="" />
<img src="decorative.png" aria-hidden="true" />