Skip to content

Instantly share code, notes, and snippets.

@DavidWells
Last active February 22, 2024 20:14
Star You must be signed in to star a gist
Save DavidWells/7d2e0e1bc78f4ac59a123ddf8b74932d to your computer and use it in GitHub Desktop.
Guide to aligning images in github readme.md files. https://davidwells.io/snippets/how-to-align-images-in-markdown

Aligning images

This is a guide for aligning images.

See the full Advanced Markdown doc for more tips and tricks

left alignment

This is the code you need to align images to the left:

<img align="left" width="100" height="100" src="https://picsum.photos/100/100">

right alignment

This is the code you need to align images to the right:

<img align="right" width="100" height="100" src="https://picsum.photos/100/100">

center alignment example

<p align="center">
  <img width="460" height="300" src="https://picsum.photos/460/300">
</p>

Markdown Formatting on steriods

If you like this, you might enjoy markdown-magic. I built it to automatically format markdown files and allow folks to sync docs/code/data from external sources.

@AuracleTech
Copy link

Stopped working

@Ringoshere
Copy link

When I move it to the left or right, the text below gets put up alongside the image. How can I avoid that happening? I tried multiple
but no luck.
This is the format I need...
Screenshot 2023-08-18 at 10 46 48 AM

@RitamChakraborty
Copy link

When I move it to the left or right, the text below gets put up alongside the image. How can I avoid that happening? I tried multiple but no luck.

You can try something like this

<img align="right" src="https://picsum.photos/300/200" alt="image" />
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five 
centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.



image

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

@bad1dea
Copy link

bad1dea commented Nov 28, 2023

Is there any way to have multiple images vertical on left.. and a code block on right side? Every time I try, the code block starts at the last image...

image

@RitamChakraborty
Copy link

Try this...

<img align="right" src="https://picsum.photos/700/480" alt="image" />
<img src="https://picsum.photos/150/100" alt="image" />
<img src="https://picsum.photos/150/100" alt="image" />
<img src="https://picsum.photos/150/100" alt="image" />
<img src="https://picsum.photos/150/100" alt="image" />

image

image

image

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment