A carousel is a slideshow component that cycles through elements like images or text, usually with controls to move forward or backward.
Click to reveal answer
beginner
Which Bootstrap class is used to create the main container for a carousel?
The <code>carousel</code> class is used on a <code><div></code> to create the main container for a Bootstrap carousel.
Click to reveal answer
intermediate
How do you add navigation controls to a Bootstrap carousel?
You add buttons with classes <code>carousel-control-prev</code> and <code>carousel-control-next</code> inside the carousel container to let users move slides backward and forward.
Click to reveal answer
intermediate
What attribute connects carousel controls to the carousel element in Bootstrap?
The data-bs-target attribute on control buttons points to the carousel's ID to link controls with the carousel.
Click to reveal answer
intermediate
Why is it important to include aria-label and aria-hidden in carousel controls?
These attributes improve accessibility by helping screen readers understand the controls and hiding decorative icons from assistive technologies.
Click to reveal answer
Which Bootstrap class is used for each slide inside a carousel?
Aitem-slide
Bslide-item
Ccarousel-slide
Dcarousel-item
✗ Incorrect
Each slide inside a Bootstrap carousel uses the class carousel-item.
What attribute should the carousel control buttons have to specify which carousel they control?
Adata-bs-slide
Bdata-bs-target
Cdata-slide-to
Ddata-target-slide
✗ Incorrect
The data-bs-target attribute points to the carousel's ID to link controls.
Which element is used to wrap the entire carousel in Bootstrap?
A<div>
B<section>
C<article>
D<main>
✗ Incorrect
A <div> with class carousel wraps the entire carousel.
What role do the carousel-control-prev and carousel-control-next classes serve?
AThey create buttons to move slides backward and forward.
BThey pause the carousel automatically.
CThey add captions to slides.
DThey style the indicators below the carousel.
✗ Incorrect
These classes create navigation buttons to move slides backward and forward.
Why should carousel controls include aria-label attributes?
ATo add color to buttons.
BTo improve keyboard navigation.
CTo help screen readers describe the controls.
DTo make the carousel slide automatically.
✗ Incorrect
The aria-label helps screen readers describe the purpose of controls.
Explain how to build a basic Bootstrap carousel with slides and navigation controls.
Think about the structure and classes needed for slides and controls.
You got /5 concepts.
Describe why accessibility is important in carousel controls and how Bootstrap supports it.
Consider users who rely on assistive technologies.
You got /5 concepts.
Practice
(1/5)
1. What is the main purpose of the .carousel-control-prev and .carousel-control-next classes in a Bootstrap carousel?
easy
A. They automatically start the carousel animation.
B. They style the carousel indicators at the bottom.
C. They add captions to each slide.
D. They create buttons to move slides backward and forward.
Solution
Step 1: Understand carousel controls
The classes .carousel-control-prev and .carousel-control-next are used to create navigation buttons on the left and right sides of the carousel.
Step 2: Identify their function
These buttons allow users to manually move the slides backward (previous) or forward (next) in the carousel.
Final Answer:
They create buttons to move slides backward and forward. -> Option D
Quick Check:
Carousel controls = navigation buttons [OK]
Hint: Controls always move slides left or right [OK]
Common Mistakes:
Confusing controls with indicators
Thinking controls add captions
Assuming controls start animation automatically
2. Which of the following is the correct HTML structure to add a previous control button in a Bootstrap 5 carousel?
The correct control button uses button with class carousel-control-prev, attributes data-bs-target and data-bs-slide="prev", and includes an icon span and a visually hidden label for accessibility.
Step 2: Compare options
Previous matches the official Bootstrap 5 syntax exactly. Other options use incorrect classes, tags, or attributes.
Final Answer:
Option A is the correct Bootstrap 5 previous control button structure. -> Option A
Quick Check:
Bootstrap 5 controls use button with data-bs-slide [OK]
Hint: Look for data-bs-slide="prev" and correct classes [OK]
Common Mistakes:
Using old Bootstrap 4 attributes like data-slide
Missing aria-hidden or visually-hidden spans
Using wrong element tags like <a> or <div>
3. Given this Bootstrap carousel snippet, what will happen when the user clicks the next control button?
B. Wrong class name; should be carousel-prev-control.
C. Missing data-bs-target attribute to specify the carousel ID.
D. Missing aria-label attribute on the button.
Solution
Step 1: Check required attributes for carousel controls
Bootstrap carousel control buttons must have data-bs-target to link the button to the carousel's ID.
Step 2: Identify missing attribute in the code
The given button lacks data-bs-target="#carouselID", so it cannot control any carousel.
Final Answer:
Missing data-bs-target attribute to specify the carousel ID. -> Option C
Quick Check:
Controls need data-bs-target to work [OK]
Hint: Always include data-bs-target with carousel ID [OK]
Common Mistakes:
Omitting data-bs-target attribute
Using wrong class names
Confusing button with anchor tag requirement
5. You want to create a Bootstrap carousel with 4 slides and add controls that loop infinitely. Which combination of attributes and classes ensures the carousel loops and controls work correctly?