0
0
Bootsrapmarkup~20 mins

Carousel slides and controls in Bootsrap - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Carousel Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
rendering
intermediate
1:30remaining
Identify the active slide in a Bootstrap carousel
Given the following Bootstrap carousel HTML snippet, which slide will be visible first when the page loads?
Bootsrap
<div id="carouselExample" class="carousel slide" data-bs-ride="carousel">
  <div class="carousel-inner">
    <div class="carousel-item">
      <img src="slide1.jpg" class="d-block w-100" alt="Slide 1">
    </div>
    <div class="carousel-item active">
      <img src="slide2.jpg" class="d-block w-100" alt="Slide 2">
    </div>
    <div class="carousel-item">
      <img src="slide3.jpg" class="d-block w-100" alt="Slide 3">
    </div>
  </div>
</div>
ASlide 2 will be visible first because it has the class 'active'.
BNo slide will be visible because none have the 'show' class.
CSlide 3 will be visible first because it is the last item in the list.
DSlide 1 will be visible first because it is the first item in the list.
Attempts:
2 left
💡 Hint
Look for the 'active' class inside the carousel items.
📝 Syntax
intermediate
1:30remaining
Which code correctly adds previous and next controls to a Bootstrap carousel?
You want to add controls to navigate slides in a Bootstrap carousel. Which option correctly implements the previous and next buttons?
A
&lt;button class="carousel-prev" type="button" data-target="#carouselExample" data-slide="prev"&gt;
  &lt;span class="carousel-prev-icon"&gt;&lt;/span&gt;
&lt;/button&gt;
&lt;button class="carousel-next" type="button" data-target="#carouselExample" data-slide="next"&gt;
  &lt;span class="carousel-next-icon"&gt;&lt;/span&gt;
&lt;/button&gt;
B
&lt;button class="carousel-control-prev" type="button" data-bs-target="#carouselExample" data-bs-slide="prev"&gt;
  &lt;span class="carousel-control-prev-icon" aria-hidden="true"&gt;&lt;/span&gt;
  &lt;span class="visually-hidden"&gt;Previous&lt;/span&gt;
&lt;/button&gt;
&lt;button class="carousel-control-next" type="button" data-bs-target="#carouselExample" data-bs-slide="next"&gt;
  &lt;span class="carousel-control-next-icon" aria-hidden="true"&gt;&lt;/span&gt;
  &lt;span class="visually-hidden"&gt;Next&lt;/span&gt;
&lt;/button&gt;
C
&lt;a class="carousel-control-prev" href="#carouselExample" role="button" data-slide="prev"&gt;
  &lt;span class="carousel-control-prev-icon" aria-hidden="true"&gt;&lt;/span&gt;
  &lt;span class="sr-only"&gt;Previous&lt;/span&gt;
&lt;/a&gt;
&lt;a class="carousel-control-next" href="#carouselExample" role="button" data-slide="next"&gt;
  &lt;span class="carousel-control-next-icon" aria-hidden="true"&gt;&lt;/span&gt;
  &lt;span class="sr-only"&gt;Next&lt;/span&gt;
&lt;/a&gt;
D
&lt;button class="carousel-control-prev" type="button" data-bs-target="#carouselExample" data-bs-slide="previous"&gt;
  &lt;span class="carousel-control-prev-icon" aria-hidden="true"&gt;&lt;/span&gt;
  &lt;span class="visually-hidden"&gt;Previous&lt;/span&gt;
&lt;/button&gt;
&lt;button class="carousel-control-next" type="button" data-bs-target="#carouselExample" data-bs-slide="next"&gt;
  &lt;span class="carousel-control-next-icon" aria-hidden="true"&gt;&lt;/span&gt;
  &lt;span class="visually-hidden"&gt;Next&lt;/span&gt;
&lt;/button&gt;
Attempts:
2 left
💡 Hint
Check the attribute names and values for Bootstrap 5 controls.
selector
advanced
1:30remaining
Which CSS selector targets only the active slide in a Bootstrap carousel?
You want to style only the currently visible slide in a Bootstrap carousel. Which CSS selector will select only the active slide?
A.carousel .active-item
B.carousel-item:active
C.carousel-item > .active
D.carousel-item.active
Attempts:
2 left
💡 Hint
Look for the class that Bootstrap adds to the visible slide.
layout
advanced
1:30remaining
How to make carousel images fully responsive and cover the slide area?
You want carousel images to fill the entire slide area without distortion and keep their aspect ratio. Which CSS approach achieves this best?
AUse <code>max-width: 100%; max-height: 100%;</code> on images.
BUse <code>width: 100%; height: auto;</code> on images.
CUse <code>object-fit: cover; width: 100%; height: 100%;</code> on images.
DUse <code>float: left; width: 100%;</code> on images.
Attempts:
2 left
💡 Hint
Think about how to crop images to fill a container while preserving aspect ratio.
accessibility
expert
2:00remaining
Which attribute improves screen reader accessibility for carousel controls?
Bootstrap carousel controls include icons but no visible text. Which attribute and element combination ensures screen readers announce the control purpose correctly?
AAdd <code>aria-label="Previous slide"</code> to the control button and include a <code>&lt;span class="visually-hidden"&gt;Previous&lt;/span&gt;</code> inside.
BAdd <code>title="Previous"</code> to the control button only.
CAdd <code>alt="Previous"</code> to the icon span inside the button.
DAdd <code>role="button"</code> to the icon span inside the button.
Attempts:
2 left
💡 Hint
Screen readers need hidden descriptive text or aria-labels on interactive elements.