Today I'm going to show you how to use HTML and a little CSS to create a basic image gallery for your blog's sidebar. This is a versatile layout that you can use for sidebar navigation, blogrolls, or just to show off your favorite images.
If you intend to use the same styles across many pages (a whole website, for example), you should move them to an external style sheet. You may also be interested in these copy/paste HTML image codes and this Image Code Editor. Very easy to use - it will take you less than 5 minutes to create your first HTML photo gallery.And you do not have to learn neither HTML or CSS! Powerful - all popular image formats are supported (jpg, png, gif, bmp and others). You can use EXIF tags in the page or image titles or print them on your images, create beautiful galleries with modern Lightbox effect or slide show. Features that help bring ideas to life. Google Web Designer gives you the power to create beautiful, engaging HTML5 content. Use animation and interactive elements to bring your creative vision to life, and enjoy seamless integration with other Google products.
In this beginner-level tutorial, I'll take you through the steps for creating a two-column sidebar gallery with six 100px square images. Each image link to a different page. At the end of the post, I've included some CSS styling options to customize the gallery.
Create a photo gallery, wizard style, and embed it into any web page that accepts HTML or publish it as an RSS feed. It is also fully compatible with several CMS programs like WordPress, Drupal, Joomla, TypePad, MediaWiki, Ning, Blogger, vBulletin, Weebly, WordPress MU and Buddy Press. As its name indicates, Web Album Maker is specially designed to create online web album or web photo gallery. With Web Album Maker, you can easily pick your favorite theme and turn your photos into a web gallery for sharing online. Different themes present the album in different ways, such as full page, sideways, full screen, overlay, etc.
What You Need To Use This Tutorial
- The option to add custom HTML widgets/gadgets to your sidebar. Blogger, self-hosted Wordpress, and Typepad Unlimited users, you're all set. Wordpress.com users will need the premium Custom CSS option to use CSS.
- Images for your sidebar. In this tutorial I'm using 100px square images. If you have a wide or narrow sidebar, you may need to adjust the image sizes. Keep in mind that the gallery looks best when all of the images are the same size.
You don't need any previous experience with HTML or CSS to use this tutorial, I'll walk you through it.
All set? Let's get started!
Upload Your Images
If you use Blogger, you can upload your images to your Picasa Web Album for your blog. If you're on self-hosted Wordpress, upload your images to your media library. Typepad users can upload images to the File Manager. No matter what platform you're on, if you prefer to use Photobucket or another image hosting service, you can!
After you've uploaded your images, you're ready to start writing the HTML for the gallery.
The HTML
Here's the skeleton template for a 6 image gallery:
I've created an editable version of this template on Codepen. You can open the editor in a new tab to code along with the tutorial. When you use Codepen to write your HTML, you'll see a preview of how your gallery will look before you add it to your blog. This is nice since you don't have to worry about making a mess on your blog while you experiment!
If you'd prefer to write your HTML 'offline', make sure you have a suitable text editor — Notepad is built-in on PCs, TextEdit is built-in on Macs (you'll need to set it up for use as an HTML editor first). Never edit HTML with a word processing program.
Let me take you through the HTML and explain what each part means.
<div>
The first line is an opening <div> tag with the class of 'sidebar-image-gallery'. In HTML and CSS, a div is like a container for the elements inside it. In this case, our gallery div will 'contain' all of your image elements.
The next 6 lines all have identical markup, but you'll fill them in with different information for each image. Let's take a look at the HTML for your gallery images, and what each of those parts means:
<a href='><img src=' width=' height=' alt='></a>
<a href='>
Here's where you enter the link your readers will go to when they click your image. So, for example, if I wanted to link my image to Google, I'd write it like this:
<a href='http://www.google.com'><img src=' width=' height=' alt='></a>
If you'd like the link to open in a new window/tab, add target='_blank' after the closing quotation mark around the URL, like this:
<a href='http://www.google.com' target='_blank'><img src=' width=' height=' alt='></a>
<img src='
Here's where to enter the direct link to your image. If you uploaded your image to your Picasa album, click on the image in your album to reach its full-sized version, then right click on the image and select the option to copy the image location. In self-hosted Wordpress, click 'edit' beneath your image in your media library and copy the File URL. Typepad users, right click the image title in your File Manager to get the direct URL.
Building on the last example, here's how I'd enter the direct link to my image:
<a href='http://www.google.com'><img src='http://www.example.com/image.png' width=' height=' alt='></a>
width=' height='
Enter the width and height of your image here. I'm demonstrating this with 100 x 100px square images:
<a href='http://www.google.com'><img src='http://www.example.com/image.png' width='100' height='100' alt='></a>
Don't add 'px' after the width or height, enter the number only.
alt='>
Alt text helps readers with visual impairments understand the images on your blog. Since we're linking the images to another page, the alt text should let your visitors know where the link is going. So, for example, I'd fill in alt text for an image linking to Google like this:
<a href='http://www.google.com'><img src='http://www.example.com/image.png' width='100' height='100' alt='Google'></a>
</a>
The closing anchor tag </a> closes the link. Don't leave this off, or your links will behave strangely!
Repeat the same process for each of your image links, making sure to fill in the destination URL first, the image source URL next, then finally the attributes of the image (width, height, and alt).
After you've completed all of the image links, you'll see that the gallery container closes with the closing </div> tag.
The CSS
If you're working along in Codepen, at this point your preview window will show you six images in a horizontal row.
We want to turn that into a two-column layout, and we'll do that with one line of CSS.
In the CSS window in Codepen, enter this:
.sidebar-image-gallery { width: 210px; }
This rule sets the width of the gallery container to 210px, which forces the 100x100px square images into two columns, like this:
Add the Gallery to Your Blog
Once your gallery is complete, you're ready to add it to your blog! We're going to add the CSS first so that your images are immediately styled as soon as you add the HTML.
The CSS
In your Codepen, copy the CSS rule in the CSS window and paste it into the custom CSS field for your blogging platform. If you're on Blogger, go to Template > Customize > Advanced > Add CSS. If you're on Typepad, go to Design > Custom CSS. On Wordpress your custom CSS location will vary. If you're using Jetpack's Custom CSS option, it's under Appearance > Edit CSS.
Save your CSS. Nothing will look different on your blog yet. You'll see the CSS working once you add the HTML.
The HTML
Next, copy everything from the HTML window and paste it into an HTML gadget/widget on your blog. On Blogger, use an HTML/JavaScript gadget. On Wordpress, enter it in a text widget. On Typepad, use the 'Embed your own HTML' option in your Content menu.
Google Page Creator
Save your new widget and you should see your new gallery appear in your sidebar. Nice work!
More Customization Options
If you're up for a little bit more CSS, there are a few simple tweaks you can make to your gallery to give it a little more style. Each of these CSS enhancements works in the current versions of Firefox, Chrome, & Safari, and in Internet Explorer 9+. IE8 is left out, as usual.
Make the Images Round
No need to open up Photoshop, you can make images round with one line of CSS! Just add this CSS rule below your .sidebar-image-gallery width rule:
.sidebar-image-gallery img { border-radius: 50%; }
Boom, round images!
Change Image Opacity on Hover
You can use the CSS opacity property and the :hover pseudo-class to make the images appear to 'fade in' or 'fade out' when they're hovered with the mouse.
To make the images appear to 'fade in' when they're hovered, you'll need to lower their opacity in their un-hovered state. To do that, add this rule to your CSS:
.sidebar-image-gallery img { opacity: .7; }
If you've used the border-radius rule demo'd above, you can add the opacity as the next line of that rule, like this:
That sets the initial opacity of your image at .7 on a scale of .1 - 1, with .1 as the lowest visible opacity and 1 as full opacity. Don't set your initial opacity too low — hover effects don't work as well on touch screen devices, and you don't want your image too faded for touchscreen visitors.
Now it's time to set the hovered opacity with the :hover pseudo-class. Here's the rule:
.sidebar-image-gallery img:hover { opacity: 1; }
Now when each of your images is hovered, it will come up to full opacity.
To reverse the effect and make the images 'fade out' a little when hovered, switch the opacity levels in the two rules so that your initial opacity is 1.
Make the Images Move
You can give the images a little bit of motion with a CSS transform. Try this to get started:
This rule makes the image tilt slightly to the left when it's hovered. If you used the opacity :hover rule up above, you can combine this :hover rule with that one, like this:
You can change the degree of the rotation by changing -10deg to a different number, positive or negative. Make sure to change all 4 instances of the number so that your effect works the same way from browser to browser.
I saved a separate Codepen with all of these extra CSS effects applied here. Experiment with it a bit and see what you come up with!
Visual LightBox
Visual LightBox is a free wizard app that helps you easily generate popup image galleries with a terrific lightbox overlay effect, in a few clicks without writing a single line of code. Just drag&drop your photos into online website builder window, press 'Publish'and your own picture slideshow with beautiful lightbox effects will openin the browser instantly! No javascript,css,html coding, no image editing, just a click to get your gallery ready.
Responsive, mobile-ready, unobtrusive, search engine friendly, translated to 31 languages!
- Cross-browser - works perfectly on all browsers (including IE6)
- GUI wizard - no coding, just point-&-click
- Responsive - smoothly adapts to any browser resolutions and device screens
- Mobile-ready - optimized for Android and iOS devices
- Search engine friendly and semantically valid
- Unobtrusive - even without Javascript, the images are still accessible
- Huge collection of fancy Lightbox themes - see website builder app
- Easy export to Joomla module or Wordpress lightbox plugin
- Keyboard navigation - use left/right arrow key to navigate
- Floating and smooth cross-fade transition
- Lightweight jQuery Lightbox code (12Kb only)
- Flickr, Photobucket, Picasa support
- Built-in FTP client - upload directly to your server
- Visual insert-to-page
- 31 language interface
Visual Lightbox v6.1 (Jan 7, 2021)
- New Neoteric template
- New thumbnail theme - Overlay Long
- Some improvements for mobile screens
- Fixed problem with pre-loading images in lightbox bootstrap carousel
Visual Lightbox v5.9 (Oct 8, 2020)
- New Ionosphere, Turquoise, Monochrome and Route templates :
- Increased the limit of Gallery IDfree website maker parameter
- Fixed problem with multiple selection. Now you can edit all selected captions
Visual Lightbox v5.7 (August 21, 2019)
- New Modern and Metro templates :
- Fixed problem with Gallery ID in Website Builder
- Bug Fixes
Visual Lightbox v5.6 (July 04, 2019)
- Now you can save your gallery as a Wordpress plugin.
For more info visit: How to Create Wordpress jQuery Lightbox - Now you can export your gallery as a joomla 2.5 module
- New Ghost template :
- Updated Prime Time, Dominion, Vista Aero templates
- Bug Fixes
Visual Lightbox v5.4 (Jan 16, 2018)
- New Dominion and Catalyst templates :
- Updated 'Insert to Page' wizard. Now you can insert galleries with different styles into the same page
- Updated Vista template
- Updated Rotate thumbnail theme
- Bug Fixes
Visual Lightbox v5.3 (Nov 16, 2014)
- Responsive - smoothly adapts to any browser resolutions and device screens
- Mobile-ready - support for iOS and Android devices
- New Prime Time template:
- New thumbnail themes - Zoom, Overlay, Caption Slide, Rotate
- Updated Noble, Chrome, Crystal, Noir, Pinboard templates:
- 'Zoom on mouseover' option - opens popup on mouseover, not a click
- jQuery updated to latest version
- Multiline description
- Byelorussian language added
- Bug Fixes
Visual Lightbox v5.0 (Jan 5, 2013)
- Close the pop up box on 'Esc' hit
- New interface languages: Hebrew and Finnish
- Updated Android and Dark Glass themes
- Support for multiple galleries in Joomla module
- Fixed import from Photobucket and Flickr
- Interface languages added to Mac version
- Bug Fixes
Visual Lightbox v4.8 (Oct 12, 2011)
- New Noble and Chrome templates
- Multi Galleries mode. Now you can specify the ID to add several galleries on the page.
- ew 漢語, Magyar, and اللغة العربية languages are added.
- Bug fixes for IE9
- jQuery core updated to v1.4.2
Visual Lightbox v4.7 (Jan 27, 2011)
- New templates are added - Noir, Crystal and Pinboard;
- Now you can create Joomla module for you Joomla website.
- Bug fixes.
Visual Lightbox v4.4 (Dec 20, 2010)
Html Gallery Page
- Description support for Photobucket and Flickr
- Major and minor bug fixes.
Visual Lightbox v4.3 (Sep 15, 2010)
- New templates are added - iPhone, Android and Aero;
- Improvements in 'Insert to Page' wizard:
- Now you can add several galleries to one page;
- Multilevel undo/redo;
- Faster page loading; - Bug fixes.
Visual Lightbox v4.0 (Aug 13, 2010)
- 'Insert to Page' option. Inserting a gallery to page becomes easier. 'Insert to Page' wizard opens a page in a browser view and you simply click inside the page to select where you want the gallery to appear and press 'Insert After'. No more HTML editing required!
Visual Lightbox v3.3 (Aug 3, 2010)
- Picassa support. Add Picassa album or a single photo to your lightbox gallery!
- New Picassa thumbnail is added.
- Slideshow Delay and Resize Speed parameters are added.
- 'Enable right click on image' option is added.
- Changing captions of all selected images at once.
Visual Lightbox v3.2 (Apr 20, 2010)
- Add images from Flickr tags to your gallery!
- 'Image description sliding' option is added. Uncheck it if you don't want to hide/show the description panel each time the picture is changed.
Visual Lightbox v3.1 (Feb 8, 2010)
- Photobucket support. Add photobucket album or a single photo to your gallery!
See the example with images from photobucket.com. - New Cloud template:
- New Mac (with titles) thumbnail.
- HTML tags in captions support! You can use any html tags inside your caption. See the example:
- New Norsk language is added.
Visual Lightbox v3.0 (January 28, 2010)
- Flickr support. Add flickr photostream, photoset or a single photo to your gallery!
See the example with images from flickr.com. - New Dark Glass template.
- The option to specify the number of columns in your photo gallery.
- Overlay shadow color and page background color.
- You can save thumbnails in PNG or JPG format and specify the quality of the generated images now.
- New Thai language is added.
Visual Lightbox v2.4 (December 21, 2009)
- The generated code is fully XHTML compliant now.
- New languages are added: Русский, Afrikaans, Việt Nam, Українська.
Visual Lightbox v2.3 (November 25, 2009)
- VisualLightBox script ported to jQuery, the most popular JavaScript framework. Now you can choose which engine to use with your image gallery - jQuery or old Prototype JS.
- Floating. Overlay image floats on scroll staying always visible.
- New smooth cross-fade transition.
- You can fit image inside the thumbnail and set background color for the thumbnails.
- Option to set watermark image, position, font, color, and transparency.
- Minor bug fixes.
Visual Lightbox v2.1 (November 13, 2009)
- The setup file didn't run on some of the PC with Win XP. This bug is fixed.
- Several fixes with FTP publishing.
Visual jQuery Lightbox2 v2.0 (October 27, 2009)
- Zoom effect and Zoom effect with overlay shadow are added;
- New Vista style and Shadow thumbnails are added;
- New Vista style template is added;
- The ability to change the order of the images in your gallery using mouse is added;
- More options for customizing the image size (stretch small images, shrink large images, preserve aspect ratio).
- New languages are added (Nederlands, Српски / Srpski, Slovenščina, Eesti, Svenska, Català, Dansk, Türkçe, Français, Česky, Lietuvių, Română, Italiano, Hrvatski).
- Text and graphic captions for thumbnails.
- Standart theme is updated.
Visual Lightbox v1.9 (June 25, 2009)
- Thumbnails in the Preview window were not refreshed after the pictures had been added. Bug was fixed.
- 'Background Color' option is added. Set the background color for transparent images.
Html Gallery Page Creator Download
Visual Lightbox v1.8 (May 6, 2009)
- New template is added - Mac and Facebook;
- New thumbnail templates are added - Mac, No Frame, No Frame Rounded;
- 'Add Images from folder...' button is added on the toolbar and into the main menu.
- Enable SlideShow and AutoPlay options are added.
- 'Number of thumbnail colums' option is added.
- Image captions for thumbnails are added.
- Bug with setting image's caption is fixed.
Visual Lightbox v1.6 (Apr 17, 2009)
- New thumbnail templates are added - Polaroid, Round Frame, Round Window, Simple HTML Frame, Sticky Notes;
- Now you can set custom size for thumbnails and select thumbnail themes!
- Sorting the images by date, caption, file name, and file size.
- By default, the caption is set as a file name of image.
- Multiple renaming. Select several images and change the caption for them at once.
- Now you can place HTML links into caption.
- Large images dynamically fit to browser window.
Visual jQuery Lightbox v1.5 (Feb 25, 2009)
- Slideshow feature is added;
- New templates are added - Slideshow Glossy, Slideshow Grey;
- Fix for Custom Size setting (for example: specify '480 0' or '0 500' to set max width/height);
- The ability to change the order of your images using 'Move Up Selected Images'/'Move Down Selected Images' buttons is added;
- New languages are added (Deutsch, Português, Spanish, Polski, Ελληνικά).
- Fixed bugs with an appearance in IE.
Visual Lightbox JS v1.2 (Jan 15, 2009) - First Release!
Visual LightBox is free for non-commercial use. If you want to use Visual LightBox on a school site, your non-commercial blog or non-profit organisation website, just download Visual LightBox and use it for free.
A license fee is required for business use.Visual LightBox Business Edition additionally provides an option to remove the Visual LightBox.com credit line as well as a feature to put your own logo to images. After you complete the payment via the secure form, you will receive a license information instantly by email. You can select the most suitable payment method: credit card, bank transfer, check, PayPal etc.
For troubleshooting, feature requests, and general help, contact Customer Support at Make sure to include details on your browser, operating system, Visual LightBox version, and a link to your page.
Q: How do I embed the lightbox image gallery into an existing page?
A:To install VisualLightBox gallery on your page you should:1. Create your gallery in VisualLightBox and publish it on a local drive in any test folder.
2. Open index.html file from the saved folder in any text editor.
3. Copy code for the HEAD section and paste it inside the HEAD/BODY section of you own webpage, for example:
Web Page Creator Html
...
<!-- Start VisualLightBox.com HEAD section -->
<link href='engine/css/vlightbox1.css' type='text/css'>
<link href='engine/css/visuallightbox.css' type='text/css' media='screen'>
<script src='engine/js/jquery.min.js' type='text/javascript'></script>
<script src='engine/js/visuallightbox.js' type='text/javascript'></script>
<!-- End VisualLightBox.com HEAD section -->
...
</head>
4. Copy code for the BODY section and paste it inside the Body section of you own webpage in the place where you want to have agallery, for example:
...
<!-- Start VisualLightBox.com BODY section -->
<div>
<a href='data/images1/image1.jpg'><img src='data/thumbnails1/image1.png' alt='Image1'></a>
<a href='data/images1/image2.jpg'><img src='data/thumbnails1/image2.png' alt='Image2'></a>
<a href='data/images1/image3.jpg'><img src='data/thumbnails1/image3.png' alt='Image3'></a>
<a href='http://visuallightbox.com'>Lightbox Images by VisualLightBox.com v5.1</a>
</div>
<script src='engine/js/vlbdata1.js' type='text/javascript'></script>
<!-- End VisualLightBox.com BODY section -->
...
</body>
5. Copy 'data' folder with images and thumbnails and 'engine' folder with .css and .js files into the same folder with your own webpage.
Q: I purchased your business license today but I don't see any way to update so the watermark is either missing or replace with mine. What do I do?
Register your Visual Lightbox application at first. Use reg. key from the license message you received after the purchase. After the registration you can remove watermarks.
Open Gallery->Properties->Templates: Watermark. Click to disable this option or use your own watermark.
Q: In previewing some of my own slides on the browser, I find the background (thumb nails visible) too busy and distracting. Is there a way to darken the background?
Html Gallery Generator
You may set the following parameter in enginejsvisuallightbox.js file in a such way:Q: How do I control the jQuery SlideShow speed?
Set the time you need.
Q:How can I add html code into the caption of dispayed images?
In VisualLightBox app select image and add html code in the caption for selected image.
For example:
Q: Is it possible to load a gallery from within image? So the gallery loads externally?
A:You should start the gallery onClick:1) Add the following function into the <head> tag:
function showLightBox()
{ Lightbox.start(document.getElementById('firstImage'));}
</script>
2) Specify the onClick event for the image (or link):
3) Set the ID for any image in your gallery (id='firstImage'), for example add it to the first image:
Html Gallery Page Creator Online
4) Use 'display: none;' property for your gallery in enginecssvlightbox1.css. Just change the following code:
display:-moz-inline-stack;
display:inline-block;
zoom:1;
*display:inline;
position:relative;
vertical-align:top;
margin:3px;
width:160px;
font-family:Trebuchet,Tahoma,Arial,sans-serif;
font-size:11px;
font-weight:normal;
text-decoration:none;
text-align:center;
opacity:0.87;
}
to:
display:-moz-inline-stack;
display:none;
zoom:1;
*display:inline;
position:relative;
vertical-align:top;
margin:3px;
width:160px;
font-family:Trebuchet,Tahoma,Arial,sans-serif;
font-size:11px;
font-weight:normal;
text-decoration:none;
text-align:center;
opacity:0.87;
}
Q: Can this be adapted so only one image is shown and then the gallery opens to flick through the rest of the images...
A:1) Use 'display: none;' property for your gallery in enginecssvlightbox1.css to hide all thumbnails. Please see the previous question (step 4).
2) Add the following parameter to show thumbnail that you want to display on the page:
for example:
<div>
<a href='data/images1/image1.jpg'><img src='data/thumbnails1/image1.png' alt='Image1'></a>
<a href='data/images1/image2.jpg' style='display: inline-block;'><img src='data/thumbnails1/image2.png' alt='Image2'></a>
<a href='data/images1/image3.jpg'><img src='data/thumbnails1/image3.png' alt='Image3'></a>
<a href='http://visuallightbox.com'>Lightbox Images by VisualLightBox.com v5.1</a>
</div>
<script src='engine/js/vlbdata1.js' type='text/javascript'></script>
<!-- End VisualLightBox.com BODY section -->
Q: How can I set the number of thumbnails columns?
Select required value from the list.
Q: I would like to center all the thumbnails and I cannot figure out how. Can you please help?
Try add VisualLightbox BODY section into DIV container or into TABLE, set container's sizes and use the alignment that you need.
Q: I want to change color of the overlay shadow? How can I do this?
A:Open enginecssvisuallightbox.css file in any text editor, find the following code:position:absolute;
top:0;
left:0;
z-index:190;
width:100%;
height:auto;
background-color:#d7d7d7;
}
and change the value of 'background-color' parameter, for example:
position:absolute;
top:0;
left:0;
z-index:190;
width:100%;
height:auto;
background-color:#000000;
}
Also, you can set overlay color you need at Gallery->Properties->Templates tab.
Q: Is it possible to make 2 or more pages instead of making one page with 40 photos...
To add separate galleries on different pages, go Gallery->Properties->Publish and specify unique ID for the gallery: Gallery ID. Insert a gallery in the usual way.
Q: I would like to reposition the Previous and Next buttons.Where do I have to go to make these changes in the code?
A:Open enginecssvisuallightbox.css file in any text editor, find the following code:#nextLinkImg { right: 0; }
Html Document Creator
and set position you need.