How to Embed a Screenshot in Markdown (GitHub Issues, READMEs and Stack Overflow)

How to Embed a Screenshot in Markdown (GitHub Issues, READMEs and Stack Overflow)

Markdown is everywhere developers write: GitHub and GitLab issues, pull requests, READMEs, wikis, Stack Overflow, Discord, Notion and documentation sites. Adding a screenshot takes one line, as long as you use the right kind of link. Here's the syntax, how to resize images, and how each platform handles them.

The syntax

![Login button overlaps the footer on mobile](https://sshot.online/f/AbC2xyz.png)

Add an optional title (shown on hover) in quotes: ![alt](https://…/image.png "Mobile view, iPhone 15").

Resizing: use HTML

Standard Markdown can't set an image size, but GitHub, GitLab and most renderers accept an HTML <img> tag:

<img src="https://sshot.online/f/AbC2xyz.png" alt="Login button overlaps the footer" width="600">

Set only the width so the height scales automatically. To show two screenshots side by side, place two <img> tags on the same line with smaller widths.

GitHub issues and pull requests

  1. Take the screenshot and copy it.
  2. Click in the comment box and press Ctrl + V (Cmd + V), or drag the file in.
  3. GitHub uploads it and inserts the Markdown for you. Edit the alt text it generates.

Using an external link instead is handy when the screenshot already exists as a link, when you want to reuse it across issues, or when you're writing in a tool that doesn't upload images. Use the direct link in Markdown syntax.

Before and after screenshots work well in pull requests. A small table keeps them side by side:

| Before | After |
|--------|-------|
| ![before](https://sshot.online/f/before.png) | ![after](https://sshot.online/f/after.png) |

README files

Stack Overflow

Other places that use Markdown

Fixing broken images

SymptomLikely causeFix
Broken icon or alt text shownThe URL is a web page, not an imageUse the direct link (which one)
Works for you, not othersThe image needs a loginUse a public link
Shows as plain textMissing ! or a space between ] and (Write ![alt](url) with no space
Image is hugeRetina screenshot at full sizeUse an HTML <img> with width

Paste a screenshot and copy the direct link, ready for ![alt](url) in GitHub, READMEs and docs.

Get a direct link for Markdown

Frequently asked questions

What is the Markdown syntax for an image?

![alt text](https://example.com/image.png). The exclamation mark makes it an image; the text in square brackets is the alt text; the URL in brackets must point to the image file.

How do I resize an image in Markdown?

Standard Markdown has no size option. On GitHub and many other sites you can use HTML instead: <img src="url" alt="text" width="600">.

How do I add a screenshot to a GitHub issue?

Paste it with Ctrl+V or drag it into the comment box. GitHub uploads it and inserts the Markdown for you. You can also paste a direct image link in Markdown syntax.

Why is my Markdown image broken?

Usually the URL points to a web page instead of the image file, the image needs a login, or there is a typo such as a space in the URL. Use a direct link ending in .png or .jpg.

Should I post code as a screenshot on Stack Overflow?

No. Post code and error messages as text so people can search and copy them. Use screenshots only for visual problems such as layout or UI bugs.

Related articles

← All guides