Bird
Raised Fist0
Bootsrapmarkup~20 mins

Carousel indicators in Bootsrap - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Carousel Indicator Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
What is the role of carousel indicators in Bootstrap?
In a Bootstrap carousel, what is the main purpose of the indicators shown below the slides?
AThey add captions to each slide for accessibility.
BThey automatically change the slide speed based on user interaction.
CThey show which slide is currently active and allow users to jump to any slide.
DThey control the carousel's autoplay pause and resume functions.
Attempts:
2 left
💡 Hint
Think about what the small dots below a carousel do when clicked.
📝 Syntax
intermediate
2:00remaining
Identify the correct Bootstrap carousel indicator syntax
Which of the following code snippets correctly creates carousel indicators for a Bootstrap carousel with 3 slides?
A
<ul class="carousel-indicators">
  <li data-target="#carouselExample" data-slide-to="0" class="active"></li>
  <li data-target="#carouselExample" data-slide-to="1"></li>
  <li data-target="#carouselExample" data-slide-to="2"></li>
</ul>
B
<div class="carousel-indicators">
  <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
  <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="1" aria-label="Slide 2"></button>
  <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="2" aria-label="Slide 3"></button>
</div>
C
<div class="carousel-indicators">
  <button data-bs-target="#carouselExample" data-bs-slide-to="0" class="active"></button>
  <button data-bs-target="#carouselExample" data-bs-slide-to="1"></button>
  <button data-bs-target="#carouselExample" data-bs-slide-to="2"></button>
</div>
D
<div class="carousel-indicators">
  <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="0" aria-label="Slide 1"></button>
  <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="1" aria-label="Slide 2"></button>
  <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="2" aria-label="Slide 3"></button>
</div>
Attempts:
2 left
💡 Hint
Bootstrap 5 uses
❓ rendering
advanced
1:30remaining
What will be the visual effect of missing the 'active' class on carousel indicators?
If none of the carousel indicator buttons have the 'active' class, what will the user see when the carousel loads?
AThe carousel will not function and will throw a JavaScript error.
BThe first indicator will be highlighted by default even without the 'active' class.
CAll indicators will be highlighted, confusing the user.
DNo indicator will appear highlighted, so users won't know which slide is active.
Attempts:
2 left
💡 Hint
Think about how CSS highlights the active indicator.
❓ selector
advanced
1:30remaining
Which CSS selector targets only the active carousel indicator button?
Given Bootstrap carousel indicators, which CSS selector correctly styles only the active indicator button?
A.carousel-indicators button.active
B.carousel-indicators > button
C.carousel-indicators button[aria-current="true"]
D.carousel-indicators button:focus
Attempts:
2 left
💡 Hint
The active indicator has a specific class assigned to it.
❓ accessibility
expert
2:00remaining
Which attribute is essential for screen readers on carousel indicators?
For carousel indicators to be accessible, which attribute must each indicator button include to describe its purpose to screen readers?
Aaria-label
Btabindex="-1"
Crole="presentation"
Daria-hidden
Attempts:
2 left
💡 Hint
This attribute provides a text description for screen readers.

Practice

(1/5)
1. What is the main purpose of carousel indicators in Bootstrap?
easy
A. To show which slide is active and allow users to select slides
B. To add captions to each slide
C. To control the speed of the carousel
D. To add navigation arrows to the carousel

Solution

  1. Step 1: Understand the role of carousel indicators

    Carousel indicators are small buttons or dots that show which slide is currently visible.
  2. Step 2: Identify user interaction purpose

    They also let users click to jump to a specific slide.
  3. Final Answer:

    To show which slide is active and allow users to select slides -> Option A
  4. Quick Check:

    Carousel indicators = show active slide + select slides [OK]
Hint: Indicators show active slide and let users pick slides [OK]
Common Mistakes:
  • Confusing indicators with captions
  • Thinking indicators control speed
  • Mixing indicators with navigation arrows
2. Which HTML element is recommended for Bootstrap carousel indicators to ensure accessibility?
easy
A. <button>
B. <div>
C. <a>
D. <span>

Solution

  1. Step 1: Identify accessible element for interaction

    Buttons are interactive elements that support keyboard and screen reader accessibility by default.
  2. Step 2: Bootstrap documentation recommendation

    Bootstrap uses <button> elements for carousel indicators to ensure proper ARIA roles and keyboard focus.
  3. Final Answer:

    <button> -> Option A
  4. Quick Check:

    Use <button> for accessible carousel indicators [OK]
Hint: Use <button> for accessible clickable indicators [OK]
Common Mistakes:
  • Using <div> which is not keyboard accessible
  • Using <a> without href causing accessibility issues
  • Using <span> which is not interactive
3. Given this snippet inside a Bootstrap carousel:
<div class="carousel-indicators">
  <button type="button" data-bs-target="#myCarousel" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
  <button type="button" data-bs-target="#myCarousel" data-bs-slide-to="1" aria-label="Slide 2"></button>
  <button type="button" data-bs-target="#myCarousel" data-bs-slide-to="2" aria-label="Slide 3"></button>
</div>

What will happen when the second button is clicked?
medium
A. The carousel will move to the first slide
B. Nothing will happen because the button lacks a class
C. The carousel will move to the second slide
D. The carousel will move to the third slide

Solution

  1. Step 1: Understand data-bs-slide-to attribute

    The attribute data-bs-slide-to="1" means the button targets the slide with index 1 (second slide, zero-based).
  2. Step 2: Identify button click effect

    Clicking this button moves the carousel to the second slide regardless of class presence.
  3. Final Answer:

    The carousel will move to the second slide -> Option C
  4. Quick Check:

    data-bs-slide-to="1" moves to second slide [OK]
Hint: data-bs-slide-to index matches slide number starting at 0 [OK]
Common Mistakes:
  • Confusing slide index starting at 1 instead of 0
  • Thinking class 'active' is required for button to work
  • Assuming no action without aria-current attribute
4. Identify the error in this carousel indicators code:
<div class="carousel-indicators">
  <button type="button" data-bs-slide-to="0" aria-label="Slide 1"></button>
  <button type="button" data-bs-slide-to="1" aria-label="Slide 2"></button>
  <button type="button" data-bs-slide-to="2" aria-label="Slide 3"></button>
</div>

What is missing that will prevent the indicators from working properly?
medium
A. Missing class="active" on all buttons
B. Missing data-bs-target attribute on buttons
C. Missing type="submit" on buttons
D. Missing aria-current="true" on all buttons

Solution

  1. Step 1: Check required attributes for carousel indicators

    Each indicator button must have data-bs-target pointing to the carousel's ID to link the button to the carousel.
  2. Step 2: Identify missing attribute impact

    Without data-bs-target, Bootstrap cannot know which carousel to control, so indicators won't work.
  3. Final Answer:

    Missing data-bs-target attribute on buttons -> Option B
  4. Quick Check:

    data-bs-target links buttons to carousel [OK]
Hint: Always add data-bs-target to indicator buttons [OK]
Common Mistakes:
  • Confusing data-bs-target with data-bs-slide-to
  • Thinking type="submit" is needed
  • Believing all buttons need class active
5. You want to create a carousel with 4 slides and indicators. Which is the correct way to mark the third indicator as active and accessible?
hard
A. <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="2" aria-label="Slide 3"></button>
B. <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="3" class="active" aria-current="true" aria-label="Slide 4"></button>
C. <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="3" aria-label="Slide 3"></button>
D. <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="2" class="active" aria-current="true" aria-label="Slide 3"></button>

Solution

  1. Step 1: Understand zero-based slide indexing

    The third slide has index 2 because counting starts at 0 (0,1,2,3 for 4 slides).
  2. Step 2: Identify correct attributes for active indicator

    The active indicator must have class="active" and aria-current="true" for accessibility.
  3. Step 3: Match aria-label to slide number

    The aria-label should say "Slide 3" to match the third slide.
  4. Final Answer:

    <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="2" class="active" aria-current="true" aria-label="Slide 3"></button> -> Option D
  5. Quick Check:

    Index 2 + active class + aria-current = correct active indicator [OK]
Hint: Active indicator uses zero-based index with class and aria-current [OK]
Common Mistakes:
  • Using slide index 3 for third slide instead of 2
  • Omitting aria-current for accessibility
  • Not adding class active to active indicator
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