How TO – Thumbnail
Learn how to create a thumbnail image.
Thumbnail Image
A thumbnail is a small image that represents a larger image (when clicked on), and is often recognized with a border around it:
How To Create a Thumbnail Image
Use an <img> element and wrap an <a> element around it. Style the image with a border and add a hover effect:
Example
<!DOCTYPE html>
<html>
<head>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
<style>
img {
border: 1px solid #ddd;
border-radius: 4px;
padding: 5px;
width: 150px;
}
img:hover {
box-shadow: 0 0 2px 1px rgba(0, 140, 186, 0.5);
}
</style>
</head>
<body>
<h2>Thumbnail Image</h2>
<p>Click on the image to enlarge it.</p>
<a target=”_blank” href=”img_forest.jpg”>
<img src=”img_forest.jpg” alt=”Forest” style=”width:150px”>
</a>
</body>
</html>
Go to our CSS Images Tutorial to learn more about how to style images.
