MDConverter
Universal In-Browser Converter
100% Client-Side Private

Markdown Images: Insert, Resize, Center and Caption

By the MDConverter team · Updated · 3 min read

Quick answer

Insert an image with an exclamation mark, alt text in square brackets and the image path or URL in parentheses: ![A red bicycle](images/bike.jpg). Markdown has no syntax for size or alignment, so use an HTML <img> tag with width (and <p align="center"> on GitHub) when you need them. Always write meaningful alt text — it is what screen readers, search engines and AI tools see.

Image syntax

It is a link with a ! in front. The text in brackets becomes the image's alt text, and an optional title in quotes becomes the hover tooltip.

Markdown
![MDConverter logo](/logo.png "MDConverter")
Result

MDConverter logo

The path here points at an image on this site. In a repository, use a relative path such as images/logo.png.

Image paths: relative, absolute and hosted

  • Relative path (best inside a repository or docs site): ![Diagram](docs/img/diagram.png) — keeps working on forks, branches and offline copies.
  • Absolute URL: ![Diagram](https://example.com/diagram.png) — needed in places with no files of their own, such as issues, forums and emails.
  • GitHub issues and comments: drag and drop or paste an image into the editor and GitHub uploads it and writes the Markdown for you.
  • Spaces in file names: wrap the path in angle brackets ![Chart](<images/q3 chart.png>) or use %20.

How to resize an image

Standard Markdown cannot set a size. Use HTML — set only width to keep the proportions:

Markdown
<img src="/logo.png" alt="MDConverter logo" width="80">
Result
MDConverter logo
Works on GitHub, GitLab, VS Code and most renderers that allow HTML. Some apps have their own syntax: Obsidian uses ![[image.png|200]] and ![alt|200](url); Kramdown and MkDocs accept ![alt](url){: width="200"}.

How to center an image

Again, HTML. On GitHub, CSS is stripped, so use the align attribute on a wrapper:

Markdown
<p align="center">
  <img src="/logo.png" alt="MDConverter logo" width="80">
</p>
Result

MDConverter logo

align is obsolete HTML, but it is the method GitHub READMEs rely on because GitHub removes style attributes. On your own site, use CSS instead.

Adding a caption

Markdown has no caption element. Common approaches:

  • Italic text on the next line — works everywhere: ![Chart](chart.png) then *Figure 1: Revenue by quarter*.
  • HTML figure: <figure><img src="chart.png" alt="…"><figcaption>Figure 1</figcaption></figure> where HTML is allowed.
  • Pandoc turns an image that is alone in its paragraph into a figure with its alt text as the caption — handy for PDFs and Word documents built with Pandoc.

Clickable images and badges

Wrap the image syntax in a link. README badges are exactly this: an image from a badge service wrapped in a link to the CI run or package page.

Markdown
[![MDConverter logo](/logo.png)](https://mdconverter.net)
Result

MDConverter logo

Different images for light and dark mode (GitHub)

GitHub supports the HTML <picture> element, so you can serve a different image depending on the reader's theme:

<picture>
  <source media="(prefers-color-scheme: dark)" srcset="logo-dark.png">
  <img alt="Project logo" src="logo-light.png">
</picture>

Writing good alt text

Describe what the image shows and why it is there, in a short sentence: ![Bar chart: revenue grew 21% in Asia Pacific](chart.png), not ![chart](chart.png) or ![image](chart.png). Leave decorative images with empty alt text ![](divider.png) so screen readers skip them. Alt text is also what survives when Markdown is given to an AI model or converted to plain text.

Images when converting Markdown

Converters run in your browser and do not download remote images on your behalf, so Markdown to Word writes a short “[Image: alt text]” placeholder where an image was — insert the picture in Word afterwards. Markdown to PDF and Markdown to HTML display images that your browser can load. Going the other way, Word to Markdown keeps image alt text.

Image support by app

AppSupportedNotes
GitHub / GitLabYesMarkdown and <img>; width/height/align kept, style removed; <picture> supported on GitHub.
ObsidianYesMarkdown images plus ![[embed]] with |width sizing.
VS Code previewYesRelative paths resolve from the file’s folder.
RedditPartlyImage uploads through the editor; external Markdown images are not embedded.
Discord, SlackNoImage syntax is not rendered; post the image or URL directly.
NotionPartlyImported Markdown images become image blocks if the URL is reachable.

Common mistakes and how to fix them

ProblemFix
Image shows as a broken iconCheck the path is relative to the Markdown file (not your working folder), the case of the file name, and that the URL is publicly reachable.
Image shows as a link insteadYou forgot the ! in front of the brackets.
width is ignoredYour app strips HTML. Resize the image file itself, or use the app’s own size syntax.
Image centered locally but not on GitHubGitHub strips style. Wrap the image in <p align="center">.

Tools for this

Frequently Asked Questions

Frequently Asked Questions About Images

Comprehensive answers to common technical, formatting, security, and compatibility questions.

Use an HTML img tag with a width attribute, such as <img src="photo.png" alt="…" width="300">. Setting only the width keeps the proportions. Obsidian also accepts ![alt|300](url) and ![[photo.png|300]].

Sources

← All Markdown lessons · Markdown cheat sheet