Display images Side by Side in GitHub Markdown (README.md)

avatar
Borislav Hadzhiev

Last updated: Apr 5, 2024
3 min

banner

# Display images Side by Side in GitHub Markdown (README.md)

The easiest way to display images side by side in GitHub markdown is to use a table.

You can define a table of N columns in your README.md file where each column stores an image.

Here is an example.

README.md
| Cat pics | Dog pics | | ----------------------------------- | ----------------------------------- | | ![cat](https://example.com/cat.png) | ![dog](https://example.com/dog.png) |

The text between the square brackets [] is the alt text for the image.

You can use the same approach when working with local images.

README.md
| Cat pics | Dog pics | | ---------------------- | ---------------------- | | ![cat](images/cat.png) | ![dog](images/dog.png) |

The example assumes that your folder structure looks as follows.

shell
├── images │ ├── cat.png │ └── dog.png └── README.md

Here is an example of how the images look on GitHub.

images side by side table two columns

The same approach can be used if you need to place more than two images side by side.

Simply add more columns to the table.

README.md
| Cat pics | Dog pics | Lizzard | | ----------------------------------- | ----------------------------------- | ------------------------------------------- | | ![cat](https://example.com/cat.png) | ![dog](https://example.com/dog.png) | ![lizzard](https://example.com/lizzard.png) |

github three images side by side

You can also specify a title for each image, so that when the user hovers over the image, the text is displayed.

README.md
| AWS | Git | | ----------------------------------------------------- | --------------------------------------------- | | ![aws bootstrap](images/aws-bootstrap.webp 'title A') | ![git hooks](images/git-hooks.webp 'title B') |

Notice that the title is specified in quotes after the path to the image.

hover over image with title

# Using HTML tags to display your images side by side in GitHub Markdown

You can also use HTML tags to display your images side by side directly in GitHub markdown.

README.md
<p float="left"> <img src="https://bobbyhadz.com/images/blog/python-print-tab/thumbnail.webp" width="33%" /> <img src="https://bobbyhadz.com/images/blog/what-aws-cdk-bootstrap-do/thumbnail.webp" width="33%" /> <img src="https://bobbyhadz.com/images/blog/aws-cdk-subnet-tags/thumbnail.webp" width="33%" /> </p>

display images side by side using tags

The code sample displays 3 images side by side.

Notice that the width attribute is set to 33%.

README.md
<img src="..." width="33%" />

You have to adjust this if you need to display more or fewer images.

For example, if displaying only 2 images, you'd use a width of 49%.

For 4 images, you'd use a width of 24%, etc.

The same approach can be used to display multiple local images side by side.

README.md
<p float="left"> <img src="images/dog.png" width="33%" /> <img src="images/cat.png" width="33%" /> <img src="images/lizzard.png" width="33%" /> </p>

If you run into issues when working with local images, check out my other article:

The example assumes that your folder structure looks as follows.

shell
├── images │ ├── cat.png │ ├── lizzard.png │ └── dog.png └── README.md

You can also set the width in pixels, it doesn't have to be set using percentages.

README.md
<p float="left"> <img src="images/dog.png" width="250" /> <img src="images/cat.png" width="250" /> <img src="images/lizzard.png" width="250" /> </p>

You can also set the height of the images.

README.md
<p float="left"> <img src="images/dog.png" height="150" width="250" /> <img src="images/cat.png" height="150" width="250" /> <img src="images/lizzard.png" height="150" width="250" /> </p>

You can use any other CSS styles when styling your images, e.g. flex.

README.md
<div style="display: flex; flex-direction: row;">> <img src="images/aws-bootstrap.webp" width="250" /> <img src="images/git-hooks.webp" width="250" /> <img src="images/python-tab.webp" width="250" /> </div>

You can also use the &nbsp; character sequence if you need to add whitespace between the images.

README.md
<p float="left"> <img src="images/aws-bootstrap.webp" height="150" width="250" /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <img src="images/git-hooks.webp" height="150" width="250" /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <img src="images/python-tab.webp" height="150" width="250" /> </p>

add whitespace between images in markdown

You can add as many or as few &nbsp; character sequences as necessary.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.