Skip to main content

Markdown Image Syntax

How to add images in Markdown. Covers the core ![alt](url) syntax, reference-style and clickable images, relative paths, sizing/alignment workarounds, and the mistakes that break them.

Basic Syntax

A Markdown image starts with an exclamation mark, followed by alt text in square brackets, followed by the image URL in parentheses.

Inline image
![A dog running in the park](https://placehold.co/600x300?text=Example+Image)
Preview

A dog running in the park

Image Titles

Add a quoted title after the URL. It renders as a tooltip on hover in most browsers and is useful for extra context. It is not a visible caption.

Image with a tooltip
![A dog running](https://placehold.co/600x300?text=Example+Image "Photo of a dog")
Preview

A dog running

Reference Images

Reference-style images keep long URLs out of your paragraphs. Use ![alt][id] inline, then define [id]: url on its own line later in the document.

Reference-style image
![MarkdownFormatting logo][logo]

[logo]: https://markdownformatting.com/favicon.png "Site logo"
Preview

MarkdownFormatting logo

Clickable Images

Wrap the image syntax in link syntax to make the image itself clickable. This is common for banners and thumbnails.

Image that links to a page
[![Example screenshot](https://placehold.co/200x100)](https://markdownformatting.com)
Preview

Example screenshot

Relative Paths

Use relative paths for images stored next to your Markdown file. The path is resolved relative to the file containing the image.

Relative image paths
![Screenshot](./screenshot.png)

![Diagram](../images/diagram.png)
Preview

Screenshot

Diagram

Sizing & Alignment

Standard Markdown cannot set width, height, or alignment. Use raw HTML when the renderer allows it. GitHub allows width and height attributes but strips style. Many static-site generators allow both.

HTML image with width
<img src="https://placehold.co/600x300?text=Example+Image" alt="Example image" width="300" />
Preview
Example image
Center an image with HTML
<p align="center">
  <img src="https://placehold.co/600x300?text=Example+Image" alt="Centered image" />
</p>
Preview

Centered image

Alt Text

Alt text describes the image for screen readers and search engines. Keep it short, accurate, and contextually relevant. Avoid phrases like "image of" because the screen reader already knows it is an image.

Good: ![A crescent moon over a dark ocean]

Bad: ![image]

Common Mistakes

The five most common reasons a Markdown image fails. Each row shows the broken version and the corrected one side by side.

Broken

[Alt text](https://example.com/image.png)

Fixed

![Alt text](https://example.com/image.png)
Missing the exclamation mark. Without ! it becomes a link, not an image.

Broken

![Alt text](https://example.com/my image.png)

Fixed

![Alt text](https://example.com/my%20image.png)
Spaces in a URL break the image reference. Percent-encode the space or wrap the URL in angle brackets.

Broken

![Alt text](example.com/image.png)

Fixed

![Alt text](https://example.com/image.png)
External URLs need a protocol. Without https:// the parser treats it as a relative path.

Broken

![Alt text](image.png

Fixed

![Alt text](image.png)
Missing the closing parenthesis. The image syntax stays unparsed.

Broken

![Alt text][logo]

[logo] https://example.com/image.png

Fixed

![Alt text][logo]

[logo]: https://example.com/image.png
Reference definitions need a colon after the bracket. [id]: url, not [id] url.

Quick Reference

SyntaxWhat it does
![alt](url)Inline image
![alt](url "title")Inline image with tooltip
![alt][id]Reference image marker
[id]: url "title"Reference image definition
[![alt](img)](url)Clickable image
![alt](./img.png)Relative-path image
<img src="" alt="" width="300" />HTML fallback for sizing

Platform Support

Images are part of standard Markdown, so they are widely supported. The differences are mainly in HTML attribute handling and relative-path resolution.

PlatformSupported?Notes
GitHubYesInline and reference images work. Relative paths resolve in the repository. GitHub strips inline style but allows width/height attributes.
GitLabYesSame as GitHub Flavored Markdown.
Reddit (new)YesImage links work; titles are ignored. Hosted image URLs must be whitelisted by Reddit.
Reddit (old)PartialImages require a direct link; old Reddit has no image upload hosting of its own.
DiscordYesEmbeds image URLs automatically. Markdown image syntax also works.
SlackYesImage URLs unfurl automatically. Markdown image syntax works in posts but not in all Block Kit surfaces.
NotionPartialPasting an image uploads it; Markdown image syntax is accepted on import but may become Notion-native.
ObsidianYesRelative paths use vault-relative paths. Wikilink embeds ![[image.png]] are the native style.
VS Code previewYesRenders inline, reference, and HTML img images. Relative paths resolve from the open file.
CommonMarkYesInline and reference images are part of the CommonMark spec.
Docusaurus / VitePress / AstroYesRelative paths resolve according to the static site config; HTML img also works.

Frequently Asked Questions

How do you add an image in Markdown?

Use inline image syntax: ![Alt text](https://example.com/image.png). The text inside the square brackets is alt text, and the URL inside the parentheses points to the image file.

What is alt text in a Markdown image?

Alt text describes the image for screen readers and appears if the image fails to load. Keep it concise and descriptive: ![A red apple on a wooden table](apple.png).

Can you add a title or caption to a Markdown image?

Yes. Add a title in double quotes after the URL: ![Alt text](image.png "My title"). Most browsers show this as a tooltip on hover. It is not a visible caption; for a true caption, use HTML or place text below the image.

How do you make an image a link in Markdown?

Wrap the image syntax in link syntax: [![Alt text](image.png)](https://example.com). The image becomes the clickable element that takes the reader to the target URL.

Can you resize or align an image in Markdown?

Standard Markdown has no syntax for image size or alignment. Use raw HTML: <img src="image.png" width="300" /> or <p align="center"><img ... /></p>. Not every renderer allows inline HTML; GitHub allows width and height attributes but strips style attributes.

Do relative paths work for images in Markdown?

Yes. Use ./image.png for an image in the same directory and ../images/diagram.png for an image in a sibling folder. The path is resolved relative to the Markdown file. On GitHub and static-site generators, the repository root is the base for absolute paths starting with /.

What is a reference-style image in Markdown?

A reference-style image separates the alt text from the URL, like a footnote: ![Alt text][id] followed later by [id]: https://example.com/image.png. This keeps long paragraphs readable and lets you reuse the same image URL.

Why is my Markdown image not showing?

Check that: the URL has a protocol for external images, there are no unescaped spaces in the URL, the closing parenthesis is present, the exclamation mark precedes the square brackets, and the relative path is correct for the renderer.

Can I use Markdown inside image alt text?

Alt text is treated as plain text. You cannot use bold, italic, or links inside it. Write a literal description, such as !['Deploy succeeded' banner with a green checkmark].

Are images supported in GitHub Markdown?

Yes. GitHub supports inline and reference images, relative repository paths, and HTML <img> tags with width and height attributes. GitHub strips style and class attributes for security.