What is the purpose of the <code>.navbar-brand</code> class in Bootstrap?
The <code>.navbar-brand</code> class is used to style the main branding element of a navbar, usually a logo or site name, making it stand out and linking it to the homepage.
Click to reveal answer
beginner
What does the navbar toggler button do in a Bootstrap navbar?
The navbar toggler button shows or hides the navigation links on smaller screens, making the navbar responsive and easy to use on mobile devices.
Click to reveal answer
beginner
Which Bootstrap class is used to create the hamburger icon for the navbar toggler?
The <code>.navbar-toggler-icon</code> class creates the hamburger icon inside the toggler button.
Click to reveal answer
intermediate
Why is the aria-controls attribute important on the navbar toggler button?
The aria-controls attribute links the toggler button to the collapsible menu it controls, improving accessibility for screen readers.
Click to reveal answer
intermediate
How does Bootstrap know which menu to show or hide when the toggler button is clicked?
Bootstrap uses the data-bs-target attribute on the toggler button to identify the collapsible menu by its ID and toggle its visibility.
Click to reveal answer
What class should you add to a link to make it the brand in a Bootstrap navbar?
A.navbar-link
B.navbar-brand
C.navbar-item
D.navbar-logo
✗ Incorrect
The .navbar-brand class is specifically for the brand element in a Bootstrap navbar.
Which attribute on the toggler button specifies the menu it controls?
Aaria-controls
Bdata-bs-toggle
Caria-expanded
Ddata-bs-target
✗ Incorrect
The data-bs-target attribute points to the ID of the collapsible menu to toggle.
What icon appears inside the navbar toggler button by default?
AA cross (X)
BA plus sign (+)
CA hamburger icon (three horizontal lines)
DA circle
✗ Incorrect
Bootstrap uses the .navbar-toggler-icon class to show a hamburger icon inside the toggler button.
Why is the navbar toggler important for mobile users?
AIt shows or hides the menu to save space
BIt hides the brand logo
CIt disables the navbar
DIt changes the navbar color
✗ Incorrect
The toggler helps show or hide the menu on small screens, making navigation easier on mobile devices.
Which attribute improves accessibility by linking the toggler to the menu it controls?
Aaria-controls
Baria-hidden
Caria-label
Daria-pressed
✗ Incorrect
The aria-controls attribute connects the toggler button to the collapsible menu for screen readers.
Explain how the navbar brand and toggler work together to create a responsive navigation bar in Bootstrap.
Think about how the brand stays visible and the menu adapts on mobile.
You got /4 concepts.
Describe the role of accessibility attributes in the Bootstrap navbar toggler.
Focus on how screen readers understand the toggler.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of the navbar-brand class in a Bootstrap navbar?
easy
A. To create a button that toggles the menu on small screens
B. To add navigation links inside the navbar
C. To display the site name or logo prominently in the navbar
D. To style the background color of the navbar
Solution
Step 1: Understand the role of navbar-brand
The navbar-brand class is used to show the website's name or logo in the navbar.
Step 2: Differentiate from other navbar elements
The toggler button is for menu control, links are for navigation, and background color is styling, not branding.
Final Answer:
To display the site name or logo prominently in the navbar -> Option C
Quick Check:
navbar-brand = site name/logo [OK]
Hint: Brand means site name or logo in navbar [OK]
Common Mistakes:
Confusing navbar-brand with navbar-toggler
Thinking navbar-brand adds navigation links
Assuming navbar-brand controls styling only
2. Which of the following is the correct HTML structure for a Bootstrap navbar toggler button?
B. Incorrect data attribute names; should use data-bs-toggle and data-bs-target
C. aria-expanded should be true by default
D. navbar-toggler-icon class is invalid
Solution
Step 1: Check Bootstrap 5 data attribute naming
Bootstrap 5 requires data-bs-toggle and data-bs-target instead of data-toggle and data-target.
Step 2: Verify other attributes
The button is properly closed, aria-expanded can be false initially, and navbar-toggler-icon is a valid class.
Final Answer:
Incorrect data attribute names; should use data-bs-toggle and data-bs-target -> Option B
Quick Check:
Bootstrap 5 uses data-bs-* attributes [OK]
Hint: Bootstrap 5 uses data-bs-toggle, not data-toggle [OK]
Common Mistakes:
Using old Bootstrap 4 data attributes
Changing aria-expanded default incorrectly
Misnaming navbar-toggler-icon class
5. You want to create a responsive Bootstrap navbar with a brand logo image and a toggler that controls the menu. Which of the following code snippets correctly implements both the brand and toggler with accessibility in mind?
hard
A.
B.
C.
D.
Solution
Step 1: Check brand logo and alt text
includes an img with descriptive alt="Site Logo", which is good for accessibility. has empty alt, which is less accessible.
Step 2: Verify toggler button attributes
uses correct Bootstrap 5 attributes data-bs-toggle="collapse" and data-bs-target="#navbarMenu" with proper aria attributes. uses old data-toggle and misses some aria attributes. incorrectly uses data-bs-toggle="dropdown" which is wrong for toggling collapse.
Final Answer:
Option A correctly implements brand logo with alt and toggler with proper attributes -> Option A
Quick Check:
Brand with alt + toggler with data-bs-toggle="collapse" [OK]
Hint: Use img alt and data-bs-toggle="collapse" for toggler [OK]
Common Mistakes:
Missing alt text on brand logo image
Using old data-toggle instead of data-bs-toggle
Using dropdown toggle instead of collapse toggle
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.