📖 Scenario: You are creating a simple photo gallery webpage for a travel blog. You want to show small clickable images (thumbnails) that link to the full-size photos.
🎯 Goal: Build a webpage using Bootstrap that displays three image thumbnails side by side. Each thumbnail should be a smaller version of the image with a border and some spacing. The thumbnails should be responsive and accessible.
📋 What You'll Learn
Use Bootstrap 5 classes to style the thumbnails
Display exactly three images as thumbnails
Each thumbnail should have a border and some padding
Images should be responsive and scale on smaller screens
Use semantic HTML and include alt text for accessibility
💡 Why This Matters
🌍 Real World
Image thumbnails are common on websites like photo galleries, e-commerce product listings, and portfolios to show small previews that link to larger images.
💼 Career
Knowing how to use Bootstrap to create responsive image thumbnails is useful for front-end web developers building user-friendly and visually appealing websites.
Progress0 / 4 steps
1
Create the HTML skeleton with Bootstrap CSS link
Write the basic HTML5 structure for a webpage with lang="en". Include the <head> section with <meta charset="UTF-8">, viewport meta tag, and link to Bootstrap 5 CSS from the official CDN. Add an empty <body> section.
Bootsrap
Hint
Remember to include the Bootstrap CSS link inside the <head> section for styling.
2
Add a container and row for thumbnails
Inside the <body>, add a Bootstrap <div> with class container. Inside it, add a <div> with class row to hold the thumbnails in a horizontal layout.
Bootsrap
Hint
Use Bootstrap's container and row classes to create a responsive layout for the thumbnails.
3
Add three thumbnail images with Bootstrap classes
Inside the row div, add three div elements each with class col-4. Inside each, add an <img> tag with class img-thumbnail. Use these exact image URLs for the src attributes: 1. https://via.placeholder.com/150?text=Photo+1 2. https://via.placeholder.com/150?text=Photo+2 3. https://via.placeholder.com/150?text=Photo+3 Also add descriptive alt text for each image: Photo 1 thumbnail, Photo 2 thumbnail, and Photo 3 thumbnail respectively.
Bootsrap
Hint
Use Bootstrap's img-thumbnail class on each <img> to get the border and padding. Use col-4 to split the row into three equal parts.
4
Make thumbnails link to full-size images
Wrap each <img> inside an <a> tag that links to the full-size image URL. Use these URLs for the href attributes: 1. https://via.placeholder.com/600?text=Photo+1+Full 2. https://via.placeholder.com/600?text=Photo+2+Full 3. https://via.placeholder.com/600?text=Photo+3+Full Also add target="_blank" to each <a> so the full image opens in a new tab.
Bootsrap
Hint
Wrap each thumbnail image in an <a> tag with the correct href and target="_blank" to open the full image in a new tab.
Practice
(1/5)
1. What does the Bootstrap class img-thumbnail do when added to an <img> tag?
easy
A. It changes the image to grayscale.
B. It makes the image full width of the container.
C. It hides the image from view.
D. It adds a border and padding to create a small framed image.
Solution
Step 1: Understand the purpose of img-thumbnail
The img-thumbnail class in Bootstrap styles images with a border and padding to look like thumbnails.
Step 2: Compare with other options
Options B, C, and D describe behaviors unrelated to img-thumbnail. Only It adds a border and padding to create a small framed image. correctly describes the border and padding effect.
Final Answer:
It adds a border and padding to create a small framed image. -> Option D
Quick Check:
Thumbnail styling = border + padding [OK]
Hint: Remember thumbnails have a border and padding by default [OK]
Common Mistakes:
Confusing thumbnail with full-width image
Thinking it hides the image
Assuming it changes image colors
2. Which of the following is the correct way to add a Bootstrap thumbnail style to an image?
easy
A. <img src='pic.jpg' class='img-thumbnail' alt='pic'>
B. <img src='pic.jpg' class='img_thumb' alt='pic'>
C. <img src='pic.jpg' class='thumbnail' alt='pic'>
D. <img src='pic.jpg' class='img-thumbnailed' alt='pic'>
Solution
Step 1: Recall the exact Bootstrap class name
The correct Bootstrap class for thumbnails is img-thumbnail, not any variation.
Step 2: Check each option's class
<img src='pic.jpg' class='img-thumbnail' alt='pic'> uses img-thumbnail exactly. Options A, B, and D use incorrect or non-existent class names.
Final Answer:
<img src='pic.jpg' class='img-thumbnail' alt='pic'> -> Option A
Quick Check:
Class name must be img-thumbnail [OK]
Hint: Use exact class img-thumbnail for thumbnails [OK]
Common Mistakes:
Misspelling the class name
Using underscores instead of hyphens
Omitting the class attribute
3. What will be the visual result of this HTML snippet?
B. The class name should be img-thumbnail with a hyphen, not underscore.
C. The src attribute is incorrect.
D. The img tag must be inside a <div>.
Solution
Step 1: Check the class name spelling
The class name uses an underscore img_thumbnail, but Bootstrap requires a hyphen: img-thumbnail.
Step 2: Verify other attributes
The alt attribute is present, and src looks correct. The img tag does not require a div wrapper for thumbnails.
Final Answer:
The class name should be img-thumbnail with a hyphen, not underscore. -> Option B
Quick Check:
Class name spelling matters: hyphen, not underscore [OK]
Hint: Check class spelling carefully: hyphen, not underscore [OK]
Common Mistakes:
Using underscore instead of hyphen in class
Thinking alt attribute affects thumbnail style
Believing img needs a div wrapper
5. You want to display three image thumbnails side by side, each with equal spacing and responsive sizing. Which Bootstrap classes and structure should you use?
Step 1: Understand layout for side-by-side thumbnails
Using Bootstrap grid with row and col classes places images side by side with equal width and spacing.
Step 2: Check each option's layout approach
<div class='row'><div class='col'><img src='1.jpg' class='img-thumbnail' alt='1'></div><div class='col'><img src='2.jpg' class='img-thumbnail' alt='2'></div><div class='col'><img src='3.jpg' class='img-thumbnail' alt='3'></div></div> uses row and col correctly. <div class='d-flex gap-3'><img src='1.jpg' class='img-thumbnail flex-fill' alt='1'><img src='2.jpg' class='img-thumbnail flex-fill' alt='2'><img src='3.jpg' class='img-thumbnail flex-fill' alt='3'></div> uses flex but may cause uneven sizing without container. Options B and C lack layout classes for spacing and responsiveness.