Skip to content

MD045 - no-alt-text

Description

This rule is triggered when an image is missing alternate text (alt text) information. Images with whitespace-only alt text (e.g. ![ ](image.jpg)) are also considered to be missing alt text. Alternate text can be specified inline as ![Alt text](image.jpg), with reference syntax as ![Alt text][ref], or with HTML as <img src="image.jpg" alt="Alt text" />.

Rationale

Alternate text is important for accessibility and describes the content of an image for people who may not be able to see it. Screen readers use alt text to describe images to visually impaired users.

Examples

Invalid

# Images without Alt Text

![](image.png)

Reference style image without alt:

![][ref]

[ref]: image.jpg

HTML image without alt attribute:

<img src="image.png" />

Valid

# Images with Alt Text

![A descriptive alt text](image.png)

Reference style image:

![Another alt text][ref]

[ref]: image.jpg "Optional title"

HTML image with alt attribute:

<img src="image.png" alt="Alt text for HTML image" />

HTML image hidden from assistive technology:

<img src="decorative.png" aria-hidden="true" />