Navbar
The navbar component builds a site header that behaves correctly at every screen size — full links across the top on desktop, collapsing into a hamburger-menu toggle on mobile — without any custom media queries or JavaScript from you.
A basic navbar
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="#">CodeAtlas</a>
<div class="navbar-nav">
<a class="nav-link" href="#">Home</a>
<a class="nav-link" href="#">Courses</a>
<a class="nav-link" href="#">About</a>
</div>
</div>
</nav>
navbar-dark tells Bootstrap the background is dark, so it renders the brand and links in light text for contrast; bg-dark actually supplies that dark background. They're separate classes on purpose — you could have a light background with navbar-dark-style text if your design called for it.
The responsive collapse
On its own, the example above doesn't collapse on mobile. The full pattern adds a toggle button and wraps the links in a collapsible container:
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="#">CodeAtlas</a>
<button class="navbar-toggler" type="button"
data-bs-toggle="collapse" data-bs-target="#navMenu">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navMenu">
<div class="navbar-nav">
<a class="nav-link" href="#">Home</a>
<a class="nav-link" href="#">Courses</a>
<a class="nav-link" href="#">About</a>
</div>
</div>
</div>
</nav>
navbar-expand-lg is the setting that controls this — it means "show everything expanded from the lg breakpoint up, collapse below it." Swap it for navbar-expand-md or navbar-expand-sm to change exactly where the collapse kicks in.
The toggle button's data-bs-toggle and data-bs-target attributes require Bootstrap's JavaScript bundle to actually be loaded on the page (a <script> tag, in addition to the CSS <link> from lesson 1) — without it, the button renders correctly but clicking it does nothing.
id (navMenu here) has to exactly match the toggle button's data-bs-target value, written as #navMenu with the leading #. Typo either one and the button renders fine but silently does nothing when clicked — a common, hard-to-spot mistake since there's no error in the console.