Navbar and navigation
Build a responsive navbar with a mobile toggler and a dropdown.
What you will be able to do
- Use navbar navbar-expand-lg for the base.
- Add a toggler with aria-controls and aria-expanded.
- Use navbar-nav for the link list.
- Mark the current page with aria-current="page".
In plain English
A navbar collapses below a breakpoint and expands above it. The toggler needs aria-controls, aria-expanded and a label. Keep the navigation structure semantic with nav and a list of links.
<nav class="navbar navbar-expand-lg bg-body-tertiary">
<div class="container">
<a class="navbar-brand" href="/">EduByte</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#main" aria-controls="main" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="main">
<ul class="navbar-nav ms-auto">
<li class="nav-item"><a class="nav-link active" aria-current="page" href="/tutorials">Tutorials</a></li>
</ul>
</div>
</div>
</nav>Your turn
EasyAdd a second nav item
Add a References link to the navbar list and mark Tutorials as current.
HTML · starter
<li class="nav-item">Check your understanding before moving on.
Knowledge checkQuestion 1
Which attribute tells assistive technology whether the collapsed menu is open?
Select an answer to continue
Study tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.