NanoFile

Markdown images

An image is written like a link with an exclamation mark in front of it. The square brackets hold the alt text, not a caption.

Image
![A blue heron in flight](heron.jpg)

A blue heron in flight

With a title
![A blue heron](heron.jpg "Photographed at dawn")

A blue heron

An image that is also a link
[![A blue heron](heron.jpg)](https://example.com)

A blue heron

Sizing, which needs HTML
<img src="heron.jpg" alt="A blue heron" width="400">
A blue heron

Markdown has no syntax for width or height. GitHub also accepts `![alt](heron.jpg#gh-dark-mode-only)` style suffixes for theme switching.

What usually goes wrong

  • The text in brackets is alt text for screen readers and for when the image fails to load. It is not a caption and is usually invisible.
  • Relative paths are resolved against wherever the file is rendered, which is why images in a README break when the same file is shown somewhere else.
  • Markdown cannot centre or float an image. That is HTML and CSS.
  • An empty alt (![](image.png)) is correct for a purely decorative image and wrong for anything carrying meaning.

Related