How to Align Images Side By Side
Ranked #195 in Internet, #6,876 overall
Use HTML and CSS to Build a Photo Gallery
This will work in Squidoo, and will work on other platforms like Wordpress that let you toggle "code" and input HTML directly. Outside of Squidoo, you may need to replace <p> with <div> to make it work.
Tip: This tutorial requires you to upload images on a web host: yours, or a professional one like Picasa or Photobucket. See How to Upload images for help.
(just in case you're curious: HTML (hypertext markup language) is the set of codes that places text and images on webpages: it's like the body and engine of a car. CSS is a set of commands ("styles") added to HTML some years later that let us fine-tune margins, sizes, fonts and layout: they're like power steering and electronic fuel injection for a car.)
Photos and computer art © Ellen Brundige. All Rights Reserved.
Side-By-Side Images: An Example
Copy the HTML Codes Below as a Template



Here's the HTML code to make side-by-side images (repace imageLocation.jpg with each graphic's URL):
<img src="imageLocation.jpg" style="width: 180px; float: left; margin-bottom: 15px; margin-right: 20px;"><img src="ImageLocation.jpg" style="width: 180px; float: left; margin-bottom: 15px; margin-right: 20px;"><img src="ImageLocation.jpg" style="width: 180px; float: left; margin-bottom: 15px;">
Here's the building blocks that make it work:
- <img src="imageLocation.jpg"> Replace imgLocation.jpg with the URL of your image. You'll need to upload it on a free image host like Picasa or Photobucket. (more help on image hosts)
- style= This allows you to add special "style" commands (CSS) that fine-tune the image.
- width: This sets the width of each image in pixels ( px)
- float: left; means "push it all the way to the left, and let whatever I write next fill the space next to it." If you think about it, this is how the letters in a paragraph of text behave: they tile from left to right, and when they run out of room, they flow onto the next line. float causes images to behave the same way. You can also float: right to tile from right to left.
- margin-right: This adds white space around each image. It's optional. You can define the same margin: on all sides, or just to one side and below as I did here.
If you want to do another row, just keep repeating the template above. When you've filled up all the available horizontal space, it tiles onto the next line just like the text in this paragraph.
TIP: All images in the row should have a margin on the right EXCEPT the far right image. The margin puts space between images. But if you add an extra margin after the final image, it could make the layout too wide; then the last image will wrap onto the next row.
Tip for Squidoo Users
The width of a Squidoo lens (the part containing our content) is 590 pixels.
So, to get three images side-by-side, I will often use graphics of 180 pixels wide with 20-pixel margins between them:
180 + 20 + 180 + 20 + 180 = 580
Not quite 590, but it's easy to remember.
Making the Images Into Clickable Links
Each image can link to a webpage. Useful for menus!
<a href="link.html"><img src="imageLocation.jpg" style="width: 180px; float: left; margin-bottom: 15px; margin-right: 20px;"></a><a href="link2.html"><img src="ImageLocation.jpg" style="width: 180px; float: left; margin-bottom: 15px; margin-right: 20px;"></a><a href="link3.html"><img src="ImageLocation.jpg" style="width: 180px; float: left; margin-bottom: 15px;"></a>
Multiple Image Photo Gallery With Captions
This Is a Little More Tricky
In this template, we'll define paragraphs as if they're rectangular zones on the page, put one image plus its caption inside each paragraph, and then tile the three paragraphs side-by-side same way we did the images above.
The key is to set the width of the containing paragraph to the exact width of the image. If the paragraph is locked at 180 pixels wide, and there's any text in it, then the text is forced to wrap at 180 pixels. That makes sure the caption is the width of the image and no more:
<span style="text-align: center; font-size: 9pt;"><p style="float: left; margin-bottom: 15px; margin-right: 20px; width: 180px;"><a href="Link1"><img src="Image1.jpg" style="width: 180px; margin-bottom: 5px;"></a><br><a href="Link1">Caption1</a></p><p style="float: left; margin-bottom: 15px; margin-right: 20px; width: 180px;"><a href="Link2"><img src="Image2.jpg" style="width: 180px; margin-bottom: 5px;"></a><br><a href="Link2">Caption2</a></p><p style="float: left; margin-bottom: 15px; width: 180px; margin-bottom: 5px;"><a href="Link3"><img src="Image3.jpg" style="width: 180px; margin-bottom: 5px;"></a><br><a href="Link3">Caption3</a></p></span>
Yikes, huh? Let's take it step by step:
1. Start with this span tag. It sets all the text small and center-aligned:
<span style="text-align: center; font-size: 9pt;">
(This span tag is optional, but I find it looks nice to have all my captions small and centered.)
NOTE: On Squidoo, use span. OFF of Squidoo, you may need div to make this work.
2. Start a new paragraph. if this is the last one on the row, REMOVE the margin-right: 20px; part:
<p style="float: left; margin-bottom: 15px; margin-right: 20px; width: 180px;">
3. If you want the image to be clickable, begin the link-code here:
<a href="Link1">
4. Place the image. Notice I added a little whitespace to the bottom so it's not bang against the caption:
<img src="Image1.jpg" style="width: 180px; margin-bottom: 5px;">
5. If you made the image clickable (step 3), close the link code:
</a>
6. I added <br> as a line break, but actually, if you set the paragraph width above, the text should wrap as needed anyway.
7. Write your caption. This is just plain text. ANYWHERE you want to have a link in the caption, just make a typical HTML link:
Here's a <a href="Link">clickable link</a>.
8. Close the paragraph:
</p>
9. Repeat steps 1-8 for each image + caption. Remember, the right-hand image in each row should NOT have margin-right (or it may take up too much horizontal space and flow onto the next row).
10. When you're done, use </span> (or </div>, if you used it above) to close the image gallery.
11. If the next paragraph after the image gallery seems to be behaving oddly, use <p style="clear: left;"> to start that paragraph. This cancels the float command, forcing the new paragraph to start on a new line instead of filling in side-by-side.
That's it!
Want to save and/or print out these instructions? Here:
Save and Print Multiple Image Gallery Template
You can save and print out these instructions in two ways:
Webpage Version
(if you save it on your desktop, you'll need to open it in your browser)
RTF Version
(Word and most text editors will open it)
Guestbook
Thanks for Dropping By
Please share and/or rate if you found this page useful!-
-
peppypatricia
May 28, 2012 @ 8:26 pm | delete
- thanks so much for this valuable resource
-
-
-
GrammaLinda
May 27, 2012 @ 10:27 pm | delete
- Helpful information. Thanks!
-
-
-
favored1
May 26, 2012 @ 4:15 am | delete
- I'm back again because I still can't get this. I'll keep coming back until I do. Thanks again... and again... and again...
-
-
-
sbellis
May 25, 2012 @ 10:38 pm | delete
- This is great stuff, thanks!
-
-
-
Atreyusmommy May 15, 2012 @ 7:07 pm | delete
- Great tips and tricks. Thank you for sharing this!
-
- Load More
My Graphics Tutorials
More Squidoo Help from Greekgeek
by Greekgeek
Storyteller, former Latin teacher, student of mythology and the ancient world: I've worn many hats, but always I've dabbled in computers and the web.
Until...
more »
- 259 featured lenses
- Top lens » Free Web Graphics: Where to Get Them (Legally!)
- This lens »
Won purple star

Explore related pages
- How To Create An Impressive Writing Website How To Create An Impressive Writing Website
- How to Build a Beautiful Site With MODx CMS (Content Management System) How to Build a Beautiful Site With MODx CMS (Content Management System)
- Create Stunning CSS Backgrounds with Images Create Stunning CSS Backgrounds with Images
- My Favourite CSS Tricks on Squidoo My Favourite CSS Tricks on Squidoo
- Free Web Site Apps & Graphics Free Web Site Apps & Graphics
- Custom Table of Contents Templates Custom Table of Contents Templates