Skip to content

Markdown Images and Alt Text

TL;DR

What it is

An image in Markdown uses link-like syntax with a leading exclamation mark. The text inside the brackets is not a caption; it is the image description that becomes alt text in HTML output.

Why it matters

Images add context fast, but they can also hide meaning from readers who do not see them. Writing useful alt text makes your content more accessible and often makes your writing clearer for everyone.

Syntax

![Short description of the image](./images/example.png)

![System architecture diagram](./images/architecture.png "Optional title")

Minimal example

Source

![The team logo](./assets/logo.png)

What it does

This embeds an image and provides alt text of The team logo.

More examples

Example 1: Repository-relative image

![Screenshot of the settings page](./assets/settings-page.png)

What it does

This links to an image relative to the current Markdown file, which is usually the most maintainable approach for repository content.

Example 2: Decorative image with empty alt text

![](./assets/divider.png)

What it does

This creates an image with empty alt text. Use this only when the image is purely decorative and adds no information needed to understand the content.

Example 3: Functional image

[![Download the PDF](./assets/download-button.png)](./files/guide.pdf)

What it does

The image acts as a link. In this case, the alt text should describe the action or destination, not the button's appearance.

Example 4: Complex image

![Quarterly revenue by region. Full text summary follows.](./assets/revenue-chart.png)

What it does

For a chart or diagram, the short alt text sets context, and the full explanation should appear nearby in normal text.

Common pitfalls

Portability and platform notes

FAQ

Is the text inside ![ ] a caption?

No. In normal Markdown image syntax, that text becomes the image description used for the alt attribute in HTML.

What makes good alt text?

It depends on purpose. Informative images need a short description of the key information. Decorative images should usually have empty alt text. Functional images should describe the action or destination. Complex images often need brief alt text plus a fuller explanation nearby.

Should I use relative or absolute links for repository images?

Use relative links when the image lives in your repository and your target platform supports relative paths for that context.

Can I leave alt text blank?

Yes, but only when the image is purely decorative and contributes no information needed to understand the page.

Practice

Related topics

References