Markdown Toolbox Logo Markdown Toolbox

How do I center an image in Markdown?

Thursday, December 28, 2023

In Markdown, centering an image can be a bit tricky as standard Markdown syntax does not provide a direct way to align images. However, you can use HTML tags within Markdown to achieve this.

Here's how to center an image:

  1. Use the HTML <div> tag with the align attribute.
  2. Place your Markdown image syntax inside the <div>.
<div align="center">![Alt text](image-url.jpg)</div>

This will center the image in the rendered Markdown document. Note that while this method works in most Markdown renderers, it might not be supported everywhere due to the mix of HTML and Markdown.