0
0
Bootsrapmarkup~20 mins

Navbar brand and toggler in Bootsrap - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Bootstrap Navbar Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
rendering
intermediate
2:00remaining
What is the visual output of this Bootstrap navbar code?
Look at the following Bootstrap 5 navbar code snippet. What will you see rendered in the browser?
Bootsrap
<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">MySite</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>
      </ul>
    </div>
  </div>
</nav>
AA navbar with brand name 'MySite' centered and no toggler button visible on any screen size.
BA horizontal navbar with brand name 'MySite' on the left, a toggler button visible on small screens, and two links 'Home' and 'Features' that collapse behind the toggler on small screens.
CA navbar with brand name 'MySite' on the right and the toggler button on the left, with links always visible.
DA vertical sidebar with brand name 'MySite' at the top and two links 'Home' and 'Features' always visible below it.
Attempts:
2 left
💡 Hint
Think about how Bootstrap's navbar-expand-lg class controls when the toggler appears and how the collapse class hides links on small screens.
📝 Syntax
intermediate
1:30remaining
Which option correctly adds an accessible label to the navbar toggler button?
Bootstrap recommends adding an aria-label to the toggler button for accessibility. Which of these button codes correctly includes an accessible label?
A
&lt;button class="navbar-toggler" type="button" aria-description="Toggle navigation"&gt;
  &lt;span class="navbar-toggler-icon"&gt;&lt;/span&gt;
&lt;/button&gt;
B
&lt;button class="navbar-toggler" type="button" aria-labelledby="toggleLabel"&gt;
  &lt;span class="navbar-toggler-icon"&gt;&lt;/span&gt;
&lt;/button&gt;
C
&lt;button class="navbar-toggler" type="button" aria-hidden="true"&gt;
  &lt;span class="navbar-toggler-icon"&gt;&lt;/span&gt;
&lt;/button&gt;
D
&lt;button class="navbar-toggler" type="button" aria-label="Toggle navigation"&gt;
  &lt;span class="navbar-toggler-icon"&gt;&lt;/span&gt;
&lt;/button&gt;
Attempts:
2 left
💡 Hint
The aria-label attribute provides a text label directly on the element for screen readers.
selector
advanced
1:30remaining
Which CSS selector targets only the navbar brand link inside a Bootstrap navbar?
You want to style only the brand link inside a Bootstrap navbar. Which CSS selector correctly targets it?
Anav > .navbar-brand
B.navbar-brand > a
C.navbar .navbar-brand
D.navbar-brand a
Attempts:
2 left
💡 Hint
Remember the brand link has the class 'navbar-brand' and is inside an element with class 'navbar'.
layout
advanced
1:30remaining
What layout behavior does the class 'navbar-expand-md' provide in Bootstrap?
If you use the class 'navbar-expand-md' on a navbar, how does it behave on different screen sizes?
AThe navbar links are collapsed behind the toggler on screens smaller than medium (md) and shown horizontally on medium and larger screens.
BThe navbar links are always collapsed behind the toggler on all screen sizes.
CThe navbar links are always shown horizontally on all screen sizes.
DThe navbar links collapse only on extra large (xl) screens and are horizontal on smaller screens.
Attempts:
2 left
💡 Hint
The 'expand-md' means expand starting at medium screens and up.
🧠 Conceptual
expert
2:00remaining
Why is it important to include the 'aria-controls' attribute on the navbar toggler button?
In Bootstrap navbars, the toggler button often has an attribute like aria-controls="navbarSupportedContent". Why is this attribute important for accessibility?
AIt tells assistive technologies which element the button controls, helping users understand what will be shown or hidden when toggled.
BIt links the button to the CSS styles of the navbar content.
CIt styles the toggler button with a special icon automatically.
DIt makes the toggler button visible only on small screens.
Attempts:
2 left
💡 Hint
Think about how screen readers announce controls and their relationships.