Markdown Image Syntax

Written by Last updated

Markdown adds an image with an exclamation mark, alt text in square brackets, and a path or URL in parentheses. That is the whole core syntax, and it works in GitHub, GitLab, VS Code, Obsidian and most documentation tools.

This page is the syntax reference: every form an image can take, what each part does, and why resizing works differently from tool to tool. If your image will not load, start with the image tutorial, which covers paths and fixes.

Open EditorDownload PDF

Syntax at a glance

Form Syntax
Basic ![Alt text](images/logo.png)
Remote image ![Alt text](https://example.com/logo.png)
With a title ![Alt text](images/logo.png "Title")
Reference-style ![Alt text][logo] plus [logo]: images/logo.png
Clickable image [![Alt text](images/logo.png)](https://example.com)
Obsidian embed ![[logo.png]]
With size, HTML an <img> tag with width, see HTML in Markdown

How the syntax works

![Project logo](images/logo.png "MDConvertHub")
Part What it does
! Marks it as an image. Without it, you get a link.
[Project logo] Alt text. Read by screen readers and shown if the image fails to load.
(images/logo.png The path or URL of the image.
"MDConvertHub") Optional title. Browsers usually show it as a hover tooltip.

Alt text versus title. Alt text is the part that matters: describe what the image shows, not the file name. The title is an extra, and many renderers or readers never show it, so do not put anything essential in it.

Reference-style images

Define the path once and use a short label wherever the image appears. This keeps long documents readable and lets you change the path in one place.

![Project logo][logo]

Later in the document: ![Logo again][logo]

[logo]: images/logo.png "Optional title"

If the label matches the alt text, you can use the short form ![logo][]. Labels are not case-sensitive.

Local path or URL?

Use a relative path for an image that lives in your project and a full https:// URL for an image hosted elsewhere. The path is measured from the Markdown file, not from the project root. For which path to write in each folder layout, see the path guide.

Resizing: Markdown has no standard syntax

CommonMark and GitHub Flavored Markdown have no way to set an image size. What works depends on the tool that renders your file:

Tool Size syntax
Any renderer that allows HTML An <img> tag with width. Works on GitHub.
Obsidian ![Alt text|250](logo.png) or ![[logo.png|250]]
Pandoc ![Alt text](logo.png){width=250px}
Kramdown (Jekyll) ![Alt text](logo.png){: width="250"}
MultiMarkdown width=250 added to the reference definition
GitHub None. A {width=...} suffix is not applied.

When your Markdown has to work on several platforms, the HTML <img> tag is the portable choice. See HTML in Markdown for its rules and the resize example in the tutorial.

Image formats

Markdown does not limit the format. If the browser can show the file and the platform allows it, the reference works.

Format Good for
PNG Screenshots, UI, transparency
JPG Photographs
SVG Logos, icons, diagrams
GIF Short animations
WebP Smaller files for the web

Standard Markdown cannot embed video. Link to it instead.

Image syntax by platform

Platform What to know
GitHub, GitLab Standard syntax in READMEs, issues and pull requests. Size needs HTML.
Obsidian Supports standard syntax and its own ![[file]] embed with |size. See the Obsidian guide.
Pandoc and Kramdown Support attribute syntax for size, shown above.
Chat and social apps Usually do not render Markdown images at all.

Image not showing?

The syntax is rarely the problem. The three most common causes:

  • The path does not match where the Markdown file is.
  • The image file was never committed or pushed.
  • The file name has different capitalization than your Markdown.

The full fix-it table is in the troubleshooting section of the tutorial.

Frequently Asked Questions

  1. 1

    What is the difference between alt text and the title in a Markdown image?

    Alt text describes the image for screen readers and appears if the image does not load. The title is an optional hover tooltip that many renderers or readers never show. Put anything important in the alt text or the page itself.

  2. 2

    How do I use a reference-style image?

    Write the image with a label, ![Alt text][logo], then define the label elsewhere in the file: [logo]: images/logo.png. The same label can be reused for the same image in several places.

  3. 3

    How can I resize a Markdown image without HTML?

    Only in tools that add their own syntax. Obsidian uses ![Alt|250](file.png), and Pandoc uses {width=250px} after the image. Standard CommonMark and GitHub have none, so use an <img> tag there.

  4. 4

    How do I embed an image in Obsidian?

    Write ![[image.png]], optionally with a size like ![[image.png|250]]. Obsidian also accepts the standard ![Alt](image.png) form.

  5. 5

    Can I put the image data directly in the Markdown file?

    Some renderers accept a base64 data: address in place of a path, but it makes the file huge and hard to edit, and some renderers, GitHub's included, may not display it. Prefer a normal file.