Challenge - 5 Problems
Responsive Navbar Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ rendering
intermediate2:00remaining
What happens when the navbar toggle button is clicked on a small screen?
Given this Bootstrap navbar code, what is the visible result after clicking the toggle button on a narrow screen?
Bootsrap
<nav class="navbar navbar-expand-lg navbar-light bg-light"> <a class="navbar-brand" href="#">Brand</a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarNav"> <ul class="navbar-nav"> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Home</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Features</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Pricing</a> </li> </ul> </div> </nav>
Attempts:
2 left
💡 Hint
Think about what the 'collapse' class does when toggled.
✗ Incorrect
On small screens, the navbar menu is hidden inside a collapsible container. Clicking the toggle button expands this container, showing the menu items below the button.
❓ selector
intermediate1:30remaining
Which Bootstrap class controls when the navbar expands?
In the class attribute 'navbar-expand-lg', what does 'lg' specify?
Attempts:
2 left
💡 Hint
Bootstrap uses size abbreviations like sm, md, lg, xl to control responsiveness.
✗ Incorrect
'lg' stands for large screens in Bootstrap's grid system. The navbar expands (shows menu horizontally) on screens 992px wide or larger.
🧠 Conceptual
advanced1:30remaining
Why is the aria-expanded attribute important on the navbar toggle button?
What role does aria-expanded="false" play in the toggle button for accessibility?
Attempts:
2 left
💡 Hint
Think about how screen readers understand interactive elements.
✗ Incorrect
The aria-expanded attribute informs assistive technologies if the collapsible menu is open (true) or closed (false), improving navigation for users relying on screen readers.
📝 Syntax
advanced1:30remaining
What error occurs if the data-bs-target attribute is missing on the toggle button?
Consider this toggle button missing data-bs-target. What happens when clicked?
Bootsrap
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button>
Attempts:
2 left
💡 Hint
The toggle button needs to know which element to control.
✗ Incorrect
Without data-bs-target, Bootstrap's JavaScript does not know which element to show or hide, so clicking the button has no effect.
❓ layout
expert2:00remaining
How to ensure the navbar toggle button is keyboard accessible?
Which practice makes the toggle button fully accessible via keyboard navigation?
Attempts:
2 left
💡 Hint
Think about semantic HTML and keyboard focus.
✗ Incorrect
A