accessaudit

How to fix images without alt text

WCAG 1.1.1 Non-text Content, level A. Rule image-alt in axe-core.

What is wrong

An <img> element has no alt attribute. A screen reader then announces "image", or reads the file name, such as "five zero five zero image underscore one dot png". The visitor does not know what the picture shows.

Who it blocks

Blind and low-vision visitors who use a screen reader, and anyone whose images fail to load.

How to fix it

Ask what the image adds to the page, and write that in a few words.

<!-- product photo: name what matters for buying -->
<img src="trowel.jpg" alt="Red steel garden trowel with wooden handle">

<!-- logo that links home: say where the link goes -->
<a href="/"><img src="logo.svg" alt="Fern and Field, home"></a>

<!-- purely decorative: empty alt, so it is skipped -->
<img src="divider-leaf.png" alt="">

Common mistakes

How the scan proposes a fix

The scan adds an alt attribute to the failing image, using its title or a readable file name when there is one, or an EDIT ME text when there is not. It then loads the fixed markup in the browser, runs the same rule again, and checks that no other attribute was changed. The words still need a human: only you know what the photo is for.

Check your own pages for free

Drag this button onto your bookmarks bar: Scan with accessaudit. Then open a page of your shop and click the bookmark: a score and the three main defects appear in a few seconds. The check runs in your browser: no content of your page leaves it, only the scanner is downloaded from this site. Try it on a demo shop.