Skip to content

Instantly share code, notes, and snippets.

@DavidWells
Last active June 21, 2026 23:23
Show Gist options
  • Select an option

  • Save DavidWells/7d2e0e1bc78f4ac59a123ddf8b74932d to your computer and use it in GitHub Desktop.

Select an option

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.

@ivanglushko

Copy link
Copy Markdown

after aligning with "center" it renders the content below as centered :(

@ivanglushko

ivanglushko commented May 12, 2023

Copy link
Copy Markdown

after aligning with "center" it renders the content below as centered :(

Fixed it instead of <div> you should use <p> and put your images in there this way it doesnt center the rest of the content.
Screenshot 2023-05-12 at 13 02 40

And tip for bordering like in the pic above you can use <kbd></kbd> tag wrap your <p> or <img> in it

@AuracleTech

Copy link
Copy Markdown

Stopped working

@Ringoshere

Copy link
Copy Markdown

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
Copy Markdown

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

bad1dea commented Nov 28, 2023

Copy link
Copy Markdown

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
Copy Markdown

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

@ruizlenato

Copy link
Copy Markdown

image
does anyone have any idea how I can fix this? the Heading line crosses over the image

@cyb3rko

cyb3rko commented Mar 20, 2024

Copy link
Copy Markdown

@ruizlenato I have seen the same issue in many different repositories now.
Seems like GitHub changed something about the Markdown rendering.

@RitamChakraborty

Copy link
Copy Markdown

Can this not be fixed with few line breaks? (<br>)


Twittergram

Twittergram

Twittergram is a bot for telegram written in golang using the telego library with localization support (i18n) and some twitter-related functions, such as downloading media and sending it to telegram.

See more at @twittergramrobot or @xgramrobot



Donate — Help keep the project alive and up-to-date.

Donate with Ko-Fi

Licensed under the terms of the GNU General Public License v3 (GPLv3)

@sarahsturgeon

Copy link
Copy Markdown

Having trouble aligning a small image vertically with my text:

Library Name0/30Easy

Example content

<details>
<summary><a href="https://whatever.com"><code>Library Name</code></a> • <strong><code>0/30</code></strong> • <img alt="Easy" src="https://img.shields.io/badge/Easy-32CD32"></summary>

Example content
</details>

align="middle" does have an effect, but not quite the one I intended...

Library Name0/30Easy

Example content

Making the image smaller seems to make it align better, but then it's too small:

Library Name0/30Easy

Example content

Any advice?

@RitamChakraborty

Copy link
Copy Markdown

Use align="center"

<details>
    <summary>
        <a href="https://whatever.com"><code>Library Name</code></a>
        <span></span>
        <strong><code>0/30</code></strong>
        <span></span>
        <img align="center" alt="Easy" src="https://img.shields.io/badge/Easy-32CD32">
    </summary>
    Example content
</details>
Library Name 0/30 Easy Example content

@sarahsturgeon

Copy link
Copy Markdown

I was confused because your post had the same issue as mine, but then I checked on Chrome and it looked good!

half-win; thank you 👍

@yvele

yvele commented Sep 11, 2024

Copy link
Copy Markdown

Looks to be not working anymore 🤔

image

@azat-io

azat-io commented Sep 11, 2024

Copy link
Copy Markdown

The same problem. It not woking anymore

@mkingvc

mkingvc commented Sep 11, 2024

Copy link
Copy Markdown

Same here. Looks like GitHub changed something recently.

@azat-io

azat-io commented Sep 11, 2024

Copy link
Copy Markdown

Looks like it was fixed

@rahaaatul

Copy link
Copy Markdown

is there a way to add rounded border outside images?

@bishos123

Copy link
Copy Markdown

Thanks guys!

@danielvartan

Copy link
Copy Markdown

👏👏👏

@Sofia-A-Fayo-Freites

Copy link
Copy Markdown

Thank you. Just what i needed.

@WillTheFarmer

Copy link
Copy Markdown

Nice, slick feature! Thank you!

@eiarcadia

Copy link
Copy Markdown

its just coming up with a white cube?
image

@kalnode

kalnode commented May 19, 2025

Copy link
Copy Markdown

In my Github repo readme, this is how I place three thumbnails in a row:

Width is explicitly set to 30% for conservative reasons. If you attempt wider, like 33.3%, the final computed style on your Github repo main page may force a wrap of the third image to a new line (undesired).

I use wrappers because many of my thumbnails link to a larger version.

<p>
	<a href="https://picsum.photos/400/400" target="_blank">
		<img src="https://picsum.photos/100/100" width="30%" height="auto">
	</a>
	<a href="https://picsum.photos/400/400" target="_blank">
		<img src="https://picsum.photos/100/100" width="30%" height="auto">
	</a>
	<a href="https://picsum.photos/400/400" target="_blank">
		<img src="https://picsum.photos/100/100" width="30%" height="auto">
	</a>
</p>

@sungsun0

Copy link
Copy Markdown

I'm not sure how to add text next to stacked images. This is what I want and I'm not sure how to execute it. The '>' are opening and closing bullet points
Screenshot 2026-04-10 160704

@RitamChakraborty

RitamChakraborty commented Apr 17, 2026

Copy link
Copy Markdown

Use `align="left" on image

<img align="left" src="https://picsum.photos/150/100" alt="image" />
<p align="right">
<h4>More About Me!</h4>
> <b>i͟n͟t͟e͟r͟e͟s͟t͟s͟<br></b>INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO 
</p>
<img align="left" src="https://picsum.photos/150/100" alt="image" />
<p>
> <b>d͟y͟f͟ + d͟n͟i͟<br></b>INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO 
</p>

image

More About Me!

> i͟n͟t͟e͟r͟e͟s͟t͟s͟
INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO

image

> d͟y͟f͟ + d͟n͟i͟
INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO INFO



Visit Discord Fonts to generate underlined text.

@sungsun0

Copy link
Copy Markdown

THANK YOU SO SO MUCHHH WAAAA

@RitamChakraborty

Copy link
Copy Markdown

THANK YOU SO SO MUCHHH WAAAA

❤️

@ire-landd

Copy link
Copy Markdown
IMG_7197

It just does this

@RitamChakraborty

Copy link
Copy Markdown

Try this.

<p align="center">
<img src="https://api.visitorbadge.io/api/visitors?path=Ire-landd&label=%EA%AB%82%E2%9D%81&labelColor=%23ff7ce&countColor=%23ffb6d&style=flat" alt="Visitor Count" />
</p>

Visitor Count

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