Challenge - 5 Problems
Bootstrap Nav Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ rendering
intermediate2:00remaining
What is the visual output of this Bootstrap nav tabs code?
Look at the following Bootstrap nav tabs code snippet. What will you see rendered in the browser?
Bootsrap
<ul class="nav nav-tabs" role="tablist"> <li class="nav-item" role="presentation"> <button class="nav-link active" id="home-tab" data-bs-toggle="tab" data-bs-target="#home" type="button" role="tab" aria-controls="home" aria-selected="true">Home</button> </li> <li class="nav-item" role="presentation"> <button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#profile" type="button" role="tab" aria-controls="profile" aria-selected="false">Profile</button> </li> </ul>
Attempts:
2 left
💡 Hint
Remember that 'nav-tabs' class creates horizontal tabs and 'active' class highlights the selected tab.
✗ Incorrect
The 'nav nav-tabs' class creates horizontal tabs. The 'nav-link active' class on the 'Home' button highlights it as the active tab. The 'Profile' tab is inactive and not highlighted.
❓ selector
intermediate1:30remaining
Which CSS selector targets the active pill in Bootstrap nav pills?
Given Bootstrap nav pills, which CSS selector correctly styles the active pill?
Attempts:
2 left
💡 Hint
Active pills use the 'active' class on the 'nav-link' element inside 'nav-pills'.
✗ Incorrect
Bootstrap applies the 'active' class to the 'nav-link' inside '.nav-pills' to indicate the active pill. So '.nav-pills .nav-link.active' targets the active pill correctly.
🧠 Conceptual
advanced1:30remaining
What ARIA role should be used on the container of Bootstrap nav tabs for accessibility?
For better accessibility, which ARIA role attribute is recommended on the container element of Bootstrap nav tabs?
Attempts:
2 left
💡 Hint
Tabs are a set of related tabs, so the container needs a role that groups them as tabs.
✗ Incorrect
The container of tabs should have role="tablist" to indicate it groups tab elements. This helps screen readers understand the structure.
❓ layout
advanced2:00remaining
How to make Bootstrap nav pills stack vertically on small screens?
You want Bootstrap nav pills to display horizontally on large screens but stack vertically on small screens. Which class combination achieves this?
Attempts:
2 left
💡 Hint
Use Bootstrap's responsive flex utility classes with the right breakpoint.
✗ Incorrect
Using 'flex-column flex-md-row' makes the nav stack vertically (column) by default and switch to horizontal (row) at medium screens and above.
📝 Syntax
expert2:30remaining
What error does this Bootstrap nav tabs code cause?
Examine this Bootstrap nav tabs snippet. What error or issue will it cause when rendered?
Bootsrap
<ul class="nav nav-tabs" role="tablist"> <li class="nav-item" role="presentation"> <a class="nav-link active" id="home-tab" data-bs-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">Home</a> </li> <li class="nav-item" role="presentation"> <a class="nav-link" id="profile-tab" data-bs-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false">Profile</a> </li> </ul> <div class="tab-content"> <div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">Home content</div> <div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">Profile content</div> </div>
Attempts:
2 left
💡 Hint
Bootstrap 5 uses 'data-bs-toggle' and 'href' for tab links to switch content.
✗ Incorrect
The code uses correct Bootstrap 5 syntax with 'data-bs-toggle' and 'href' attributes. The active tab has 'aria-selected="true"'. This code works correctly with no errors.