Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add a caption container inside a Bootstrap carousel item.
Bootsrap
<div class="carousel-item active"> <img src="slide1.jpg" class="d-block w-100" alt="Slide 1"> <div class="[1]"> <h5>First Slide</h5> <p>This is the first slide caption.</p> </div> </div>
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect class names like 'carousel-item-caption' or 'carousel-text' which do not exist in Bootstrap.
Forgetting to add the caption container inside the carousel item.
✗ Incorrect
The Bootstrap class for captions inside carousel items is 'carousel-caption'. It positions the caption text properly over the image.
2fill in blank
mediumComplete the code to add a caption title inside the carousel caption container.
Bootsrap
<div class="carousel-caption d-none d-md-block"> <[1]>Welcome to Our Site</[1]> <p>Enjoy the best experience.</p> </div>
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-heading tags like
or for the caption title.
Using
which might be too large and not typical for captions.
✗ Incorrect
Bootstrap examples commonly use
for carousel caption titles to keep headings clear and accessible.
3fill in blank
hardFix the error in the caption container class to make the caption visible on medium and larger screens.
Bootsrap
<div class="carousel-caption [1]"> <h5>Slide Title</h5> <p>Slide description here.</p> </div>
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'd-none d-sm-block' which shows the caption starting from small (sm) screens, whereas the standard is from medium (md).
Using 'd-block d-md-none' which hides caption on medium and larger screens.
✗ Incorrect
The class 'd-none d-md-block' hides the caption on small screens and shows it on medium and larger screens, which is the Bootstrap recommended way.
4fill in blank
hardFill both blanks to create a caption with a title and a paragraph inside a carousel item.
Bootsrap
<div class="carousel-item"> <img src="slide2.jpg" class="d-block w-100" alt="Slide 2"> <div class="[1]"> <[2]>Second Slide Title</[2]> <p>This is the second slide caption.</p> </div> </div>
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect container class like 'carousel-text'.
Using heading tags that are too large or not typical like
.
✗ Incorrect
The caption container uses 'carousel-caption' class. The heading inside captions is often
for proper size and style.
5fill in blank
hardFill all three blanks to create a carousel caption with a title, a subtitle, and a paragraph.
Bootsrap
<div class="carousel-caption [1]"> <h5>[2]</h5> <h6>[3]</h6> <p>Enjoy our amazing features.</p> </div>
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong display classes that hide captions on all screens.
Mixing up title and subtitle text.
✗ Incorrect
The caption is visible on medium and larger screens using 'd-none d-md-block'. The title is 'Welcome!' and the subtitle is 'Your journey starts here'.
Practice
1. What is the purpose of the
carousel-caption class in a Bootstrap carousel?easy
Solution
Step 1: Understand the role of carousel-caption
Thecarousel-captionclass is used inside eachcarousel-itemto add text overlays on slides.Step 2: Differentiate from other carousel features
Other options control speed, navigation, or styling but do not add text overlays.Final Answer:
To add text overlays on each slide explaining the content -> Option AQuick Check:
carousel-caption adds text overlays = C [OK]
Hint: Remember captions explain slides visually [OK]
Common Mistakes:
- Confusing caption with navigation controls
- Thinking it changes slide speed
- Assuming it styles background color
2. Which of the following is the correct way to add a caption inside a Bootstrap carousel slide?
easy
Solution
Step 1: Identify correct caption container
The Bootstrap documentation specifies using<div class='carousel-caption'>inside eachcarousel-item.Step 2: Check other options for correctness
<caption>is for tables,carousel-textis not a Bootstrap class, andspanis less common and outside the item is incorrect.Final Answer:
<div class='carousel-caption'>Caption Text</div> inside carousel-item -> Option BQuick Check:
Use div.carousel-caption inside carousel-item = B [OK]
Hint: Use div with class carousel-caption inside each slide [OK]
Common Mistakes:
- Using <caption> tag which is for tables
- Placing caption outside carousel-item
- Using wrong class names like carousel-text
3. Given this snippet inside a Bootstrap carousel slide:
What will be the alignment of the caption text when rendered?
<div class='carousel-caption text-start'>Caption</div>
What will be the alignment of the caption text when rendered?
medium
Solution
Step 1: Understand Bootstrap text alignment classes
The classtext-startaligns text to the left side in Bootstrap.Step 2: Apply alignment to carousel-caption
Sincecarousel-captioncontainstext-start, the caption text will appear left aligned on the slide.Final Answer:
Text aligned to the left side of the slide -> Option DQuick Check:
text-start means left aligned = A [OK]
Hint: text-start means left alignment in Bootstrap [OK]
Common Mistakes:
- Confusing text-start with center or right alignment
- Assuming captions are always centered
- Thinking text-start hides text
4. You wrote this code inside a Bootstrap carousel slide:
But the caption text does not appear on the slide. What is the likely cause?
<div class='carousel-caption text-center'>Welcome</div>
But the caption text does not appear on the slide. What is the likely cause?
medium
Solution
Step 1: Check caption placement rules
Bootstrap requirescarousel-captionto be inside acarousel-itemfor it to show properly.Step 2: Evaluate other options
text-centerdoes not hide text, captions must be insidecarousel-inner, anddivis the correct tag.Final Answer:
Missing carousel-item wrapper around the caption -> Option AQuick Check:
Caption must be inside carousel-item = A [OK]
Hint: Always nest captions inside carousel-item div [OK]
Common Mistakes:
- Placing caption outside carousel-item
- Thinking text-center hides text
- Using wrong tag for caption
5. You want to create a Bootstrap carousel with three slides, each having a caption aligned differently: first left, second center, third right. Which code snippet correctly applies these caption alignments?
hard
Solution
Step 1: Match caption alignment classes to slides
The first slide usestext-startfor left alignment, second usestext-centerfor center, and third usestext-endfor right alignment.Step 2: Verify code structure and correctness
Each caption is inside itscarousel-itemwith correct alignment classes matching the requirement.Final Answer:
Code snippet with first left, second center, third right using text-start, text-center, text-end respectively -> Option CQuick Check:
Use text-start, text-center, text-end for left, center, right captions = D [OK]
Hint: Use text-start, text-center, text-end for left, center, right [OK]
Common Mistakes:
- Mixing alignment classes order
- Using same alignment for all captions
- Placing captions outside carousel-item
Recommended
Ready to prove it?
Pass the test and this pattern moves unknown
10 questions ~5 mineasy hard
