The CSS Anthology366
Figure 9.40. Building an image gallery of thumbnails using CSS
This solution uses a simple list for the album images, and positions them using
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="" lang="en-US">
<title>CSS photo album</title>
<meta http-equiv="content-type"
content="text/html; charset=utf-8" />
<link href="gallery.css" rel="stylesheet" type="text/css" />
<ul id="albumlist">
367CSS Positioning and Layout
<li><img src="thumb1.jpg" alt="Candle" width="240"
height="160" />A light in the darkness</li>
<li><img src="thumb2.jpg" alt="Pete Ryder" width="240"
height="160" />Pete Ryder</li>
<li><img src="thumb3.jpg" alt="La Grande Bouffe" width="240"
height="160" />La Grande Bouffe</li>
<li><img src="thumb4.jpg" alt="sculpture" width="240"
height="160" />Sculpture</li>
<li><img src="thumb5.jpg" alt="Duck stretching wings" width="240"
height="160" />Splashing about</li>
<li><img src="thumb6.jpg" alt="Duck" width="240" height="160"
<li><img src="thumb7.jpg" alt="Red leaves" width="240"
height="160" />Red</li>
<li><img src="thumb8.jpg" alt="Autumn leaves" width="240"
height="160" />Autumn</li>
body {
background-color: #FFFFFF;
color: #000000;
margin: 0;
padding: 0;
#albumlist {
list-style-type: none;
#albumlist li {
float: left;
width: 240px;
margin-right: 6px;
margin-bottom: 10px;
font: bold 0.8em Arial, Helvetica, sans-serif;
color: #333333;
#albumlist img {
display: block;
border: 1px solid #333300;

Get The CSS Anthology, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.