# markdown/require-alt-text

> Require alternative text for images

The alternative text is what a screen reader reads out, and what everybody sees when the image doesn't load. Without it, those readers get nothing.

`<img>` elements in HTML are checked too. `alt=""` marks an image as decorative, so it's allowed, and so is `aria-hidden="true"`.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. It needs an ESLint config that says which files are in the language:

{/* skip */}

```js eslint.config.js
import markdown from "@eslint/markdown";

export default [
  {
    files: ["**/*.md"],
    plugins: { markdown },
    language: "markdown/commonmark",
    rules: { "markdown/require-alt-text": "error" },
  },
];
```

It also works with `markdown/gfm`.

{/* End of the generated section. */}

## Examples

Reported:

{/* bad {"count": 3} */}

```md
![](./dashboard.png)

![][dashboard]

<img src="./dashboard.png">

[dashboard]: ./dashboard.png
```

Not reported:

{/* good */}

```md
![The dashboard](./dashboard.png)

<img src="./dashboard.png" alt="The dashboard">

<img src="./divider.png" alt="">

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