What is the purpose of the Bootstrap figure component?
The Bootstrap figure component is used to display images with optional captions in a clean, semantic way. It groups an image and its caption together for better structure and styling.
Click to reveal answer
beginner
Which Bootstrap class is used to style the caption text inside a <code>figure</code>?
The class figure-caption is used to style the caption text inside a figure component.
Click to reveal answer
beginner
How do you make a responsive image inside a Bootstrap figure?
Add the Bootstrap class img-fluid to the <img> tag inside the figure. This makes the image scale nicely on different screen sizes.
Click to reveal answer
beginner
Write the basic HTML structure of a Bootstrap figure with an image and a caption.
Use this structure:
<figure class="figure">
<img src="image.jpg" class="figure-img img-fluid rounded" alt="Description">
<figcaption class="figure-caption">Caption text here.</figcaption>
</figure>
Click to reveal answer
beginner
Why should you always include the alt attribute on images inside a figure?
The alt attribute provides alternative text for screen readers and helps with accessibility. It describes the image content for users who cannot see it.
Click to reveal answer
Which HTML element is used to group an image and its caption in Bootstrap's figure component?
A<div>
B<section>
C<figure>
D<article>
✗ Incorrect
The <figure> element semantically groups an image and its caption.
What class should you add to an image inside a figure to make it responsive in Bootstrap?
Aimg-responsive
Bimg-rounded
Cimg-thumbnail
Dimg-fluid
✗ Incorrect
The class img-fluid makes images scale nicely to the parent container.
Which class styles the caption text inside a Bootstrap figure?
Acaption-text
Bfigure-caption
Cimg-caption
Dtext-caption
✗ Incorrect
The figure-caption class is used for caption styling.
What is the correct way to add a caption inside a figure?
A<figcaption>Caption</figcaption>
B<div class='caption'>Caption</div>
C<caption>Caption</caption>
D<p class='caption'>Caption</p>
✗ Incorrect
The <figcaption> element is the semantic way to add captions inside <figure>.
Why is it important to include the alt attribute on images?
AFor accessibility and screen readers
BTo add a tooltip
CFor SEO only
DTo change image size
✗ Incorrect
The alt attribute helps screen readers describe images to users who cannot see them.
Explain how to create a Bootstrap figure component with an image and caption that works well on all screen sizes.
Think about grouping, responsive images, and caption styling.
You got /4 concepts.
Describe why semantic HTML elements like figure and figcaption are important in web development.
Consider how these elements help both users and search engines.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of the Bootstrap figure component?
easy
A. To add buttons below images
B. To create a navigation menu with images
C. To group images and their captions together with proper styling
D. To make images clickable links
Solution
Step 1: Understand the figure component role
The Bootstrap figure component is designed to group an image and its caption in a semantic and styled way.
Step 2: Identify correct usage
It uses classes like figure-img for the image and figure-caption for the caption, ensuring proper layout and responsiveness.
Final Answer:
To group images and their captions together with proper styling -> Option C
Quick Check:
Figure groups image + caption = A [OK]
Hint: Figure groups image and caption together visually [OK]
Common Mistakes:
Thinking figure creates navigation menus
Confusing figure with button groups
Assuming figure makes images clickable
2. Which of the following is the correct way to add a caption inside a Bootstrap figure?
easy
A. <figcaption class='figure-caption'>Caption text</figcaption>
B. <caption class='figure-caption'>Caption text</caption>
C. <div class='figure-caption'>Caption text</div>
D. <span class='figure-caption'>Caption text</span>
Solution
Step 1: Identify the semantic tag for captions in figures
The correct HTML tag for captions inside a figure is <figcaption>.
Step 2: Confirm Bootstrap class usage
Bootstrap uses the class figure-caption on the <figcaption> tag to style captions properly.
Final Answer:
<figcaption class='figure-caption'>Caption text</figcaption> -> Option A
Quick Check:
Use <figcaption> with figure-caption class = D [OK]
Hint: Caption uses <figcaption> with class figure-caption [OK]
Common Mistakes:
Using <caption> instead of <figcaption>
Using generic <div> or <span> without semantic meaning
Omitting the figure-caption class
3. What will be the visual result of this Bootstrap figure code?
The image has figure-img and img-fluid, which is correct for Bootstrap figure images.
Step 2: Check caption classes
The <figcaption> is missing the figure-caption class, which is needed for proper Bootstrap styling.
Final Answer:
Missing figure-caption class on <figcaption> -> Option A
Quick Check:
Caption needs figure-caption class = B [OK]
Hint: Caption must have figure-caption class for styling [OK]
Common Mistakes:
Forgetting figure-caption class on caption
Thinking alt attribute is optional
Replacing semantic figure tag with div
5. You want to create a responsive Bootstrap figure with an image that has a circular shape and a caption centered below it. Which code snippet achieves this correctly?