Skip to content

img-alt

Reports an <img> with no alt attribute (WCAG H37). One hidden from assistive technology (aria-hidden="true", role="presentation" or none) is left alone, unless skip_hidden is off. A bound [alt] or :alt counts. With name_counts, so does a non-empty aria-label or aria-labelledby. With other_elements, an <area>, an <object> (also named by title) and an <input type="image"> need one too.

With no alt a screen reader reads the file name, and a browser that does not load the image shows nothing. An alt is also what search engines index for the image.

To fix, add an alt that says what the image shows, or alt="" if it is only decoration.

Reported
...
<script type="module"></script>
<script></script>
<img src="a.png">
<img src="a.png" alt="">
<img src="a.png" role="presentation">
angular:
lint:
rules:
img-alt:
level: warn # off (default), warn, error
options:
skip_hidden: true
other_elements: false
name_counts: false
html:
lint:
rules:
img-alt:
level: warn # off (default), warn, error
options:
skip_hidden: true
other_elements: false
name_counts: false
svelte:
lint:
rules:
img-alt:
level: warn # off (default), warn, error
options:
skip_hidden: true
other_elements: false
name_counts: false
vue:
lint:
rules:
img-alt:
level: warn # off (default), warn, error
options:
skip_hidden: true
other_elements: false
name_counts: false
Option Type Default Description
skip_hidden bool true Leave out an element hidden from assistive technology (aria-hidden, role="presentation" or none).
other_elements bool false Also check <area>, <object> and <input type="image">.
name_counts bool false A non-empty aria-label or aria-labelledby (and title on <object>) counts as the text alternative.

Enabled by the presets: html/html-validate-recommended, html/html-eslint-recommended, html/angular-eslint-recommended.

Suppress one line with sudsy-disable-next-line img-alt in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
angular-eslint alt-text partial other_elements covers <area>, <object> and <input type="image">
html-eslint require-img-alt full
html-validate wcag/h37 partial an img without alt unless aria-hidden or a presentation role