Bird
Raised Fist0
Bootsrapmarkup~20 mins

Figure component in Bootsrap - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Bootstrap Figure Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ rendering
intermediate
2:00remaining
What is the visual output of this Bootstrap figure code?
Look at the following HTML code using Bootstrap's figure component. What will you see rendered in the browser?
Bootsrap
<figure class="figure">
  <img src="https://via.placeholder.com/150" class="figure-img img-fluid rounded" alt="Placeholder image">
  <figcaption class="figure-caption">A simple placeholder image with caption.</figcaption>
</figure>
AAn image with rounded corners and a caption below it in smaller italic text.
BAn image with sharp corners and a caption above it in bold text.
COnly a caption text is shown, no image is visible.
DAn image with a border but no caption is displayed.
Attempts:
2 left
💡 Hint
Remember that Bootstrap's figure-caption is styled to appear below the image in smaller italic text.
❓ selector
intermediate
1:30remaining
Which CSS selector targets the caption text inside a Bootstrap figure component?
You want to style only the caption text inside a Bootstrap figure component. Which CSS selector will correctly select it?
Afigure .caption-text
B.figure-caption img
C.figure figcaption
D.figure-img figcaption
Attempts:
2 left
💡 Hint
The caption is inside a
element that is a child of an element with class 'figure'.
🧠 Conceptual
advanced
1:30remaining
What accessibility feature does the
element provide in a figure component?
Why is it important to use the
element inside a figure component for accessibility?
AIt provides a textual description of the image that screen readers can read aloud.
BIt automatically resizes the image for mobile devices.
CIt adds a decorative border around the image.
DIt hides the image from keyboard navigation.
Attempts:
2 left
💡 Hint
Think about how users who cannot see images understand the content.
❓ layout
advanced
2:00remaining
How to align a Bootstrap figure component to the right side of the page?
You want the entire figure component (image and caption) to appear aligned to the right side of the page. Which class or style should you add?
Bootsrap
<figure class="figure">
  <img src="https://via.placeholder.com/150" class="figure-img img-fluid rounded" alt="Placeholder image">
  <figcaption class="figure-caption">Caption text here.</figcaption>
</figure>
AAdd class "text-end" to the <img> element.
BAdd class "float-end" to the <figure> element.
CAdd style "margin-left: auto;" to the <figcaption> element.
DAdd class "d-flex justify-content-center" to the <figure> element.
Attempts:
2 left
💡 Hint
Bootstrap uses float utility classes to float elements left or right.
📝 Syntax
expert
2:00remaining
What error occurs if you omit the alt attribute in the tag inside a figure?
Consider this code snippet inside a Bootstrap figure component:
Image caption
What accessibility or validation issue arises from this?
Bootsrap
<figure class="figure">
  <img src="image.jpg" class="figure-img img-fluid rounded">
  <figcaption class="figure-caption">Image caption</figcaption>
</figure>
AThe image will automatically have a default alt text added.
BThe browser throws a syntax error and does not render the image.
CThe caption text will not display under the image.
DThe image is ignored by screen readers, causing accessibility issues.
Attempts:
2 left
💡 Hint
Alt text is important for screen readers to describe images.

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

  1. 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.
  2. 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.
  3. Final Answer:

    To group images and their captions together with proper styling -> Option C
  4. 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

  1. Step 1: Identify the semantic tag for captions in figures

    The correct HTML tag for captions inside a figure is <figcaption>.
  2. Step 2: Confirm Bootstrap class usage

    Bootstrap uses the class figure-caption on the <figcaption> tag to style captions properly.
  3. Final Answer:

    <figcaption class='figure-caption'>Caption text</figcaption> -> Option A
  4. 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?
<figure class='figure'>
  <img src='flower.jpg' class='figure-img img-fluid rounded' alt='Flower'>
  <figcaption class='figure-caption text-end'>A beautiful flower</figcaption>
</figure>
medium
A. Only the caption text appears, image is hidden
B. An image of a flower with caption centered below, image corners sharp
C. An image of a flower with caption above the image, image corners rounded
D. An image of a flower with a caption aligned to the right below it, image corners rounded

Solution

  1. Step 1: Analyze image classes

    The image uses figure-img, img-fluid for responsiveness, and rounded for rounded corners.
  2. Step 2: Analyze caption classes

    The caption uses figure-caption and text-end, which aligns the caption text to the right below the image.
  3. Final Answer:

    An image of a flower with a caption aligned to the right below it, image corners rounded -> Option D
  4. Quick Check:

    Rounded image + right-aligned caption = A [OK]
Hint: Check classes: rounded image + text-end caption = right aligned [OK]
Common Mistakes:
  • Assuming caption is centered by default
  • Ignoring the rounded class effect
  • Thinking caption appears above image
4. Identify the error in this Bootstrap figure code:
<figure>
  <img src='dog.jpg' class='figure-img img-fluid' alt='Dog'>
  <figcaption>A cute dog</figcaption>
</figure>
medium
A. Missing figure-caption class on <figcaption>
B. Missing figure-img class on <img>
C. The alt attribute is missing on the image
D. The figure tag should be replaced with div

Solution

  1. Step 1: Check image classes

    The image has figure-img and img-fluid, which is correct for Bootstrap figure images.
  2. Step 2: Check caption classes

    The <figcaption> is missing the figure-caption class, which is needed for proper Bootstrap styling.
  3. Final Answer:

    Missing figure-caption class on <figcaption> -> Option A
  4. 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?
hard
A. <figure class='figure'> <img src='profile.jpg' class='figure-img rounded-circle' alt='Profile'> <figcaption class='figure-caption'>User Profile</figcaption> </figure>
B. <figure class='figure'> <img src='profile.jpg' class='figure-img img-fluid rounded-circle' alt='Profile'> <figcaption class='figure-caption text-center'>User Profile</figcaption> </figure>
C. <figure> <img src='profile.jpg' class='img-fluid rounded' alt='Profile'> <figcaption class='text-center'>User Profile</figcaption> </figure>
D. <figure class='figure'> <img src='profile.jpg' class='figure-img img-fluid rounded' alt='Profile'> <figcaption class='figure-caption text-start'>User Profile</figcaption> </figure>

Solution

  1. Step 1: Ensure figure container and image classes

    The figure uses class figure. The image uses figure-img for styling, img-fluid for responsiveness, and rounded-circle for circular shape.
  2. Step 2: Check caption classes for alignment

    The caption uses figure-caption and text-center to center the caption below the image.
  3. Final Answer:

    Code snippet with figure, figure-img img-fluid rounded-circle, and figure-caption text-center -> Option B
  4. Quick Check:

    Circle image + centered caption + responsive = C [OK]
Hint: Use rounded-circle + img-fluid + figure-caption text-center [OK]
Common Mistakes:
  • Omitting img-fluid for responsiveness
  • Using rounded instead of rounded-circle for circle shape
  • Not centering caption text
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard