Markdown Toolbox Logo Markdown Toolbox
Home
Blog

How do I Add an Image Caption in Markdown?

Monday, December 18, 2023

Adding captions to images in Markdown can enhance the understanding and context of the image. While standard Markdown does not directly support image captions, there are ways to include them.

Using Alt Text as a Caption

The simplest method is to use the alt text of the image to serve as a caption:

![This is the image caption](image-url.jpg)

This will render as an image with the alt text, which can act as a caption.

HTML Method

For a more explicit caption, you can use HTML tags:

<figure>
    <img src="image-url.jpg" alt="Alt text" />
    <figcaption>This is the image caption</figcaption>
</figure>

This method renders an image with a caption below it. The <figure> tag is a semantic HTML element used to represent self-contained content, often with a caption (<figcaption>), and is well-suited for images.

Markdown Renderers with Caption Support

Some Markdown renderers or extensions support syntax for image captions. For example, Pandoc has a syntax for figures with captions. Check if your Markdown environment has such features.

Remember, the appearance of captions may vary depending on the Markdown renderer or platform you're using, so it's important to test how your document renders in the intended environment.