CHAPTER 11
Beginner
Bootstrap Navbar and Navigation
Updated: May 18, 2026
5 min read
# CHAPTER 11
Bootstrap Navbar and Navigation
1. Chapter Introduction
The navbar is the first component users interact with on any website. Bootstrap's navbar component handles everything: brand logo, navigation links, a search bar, dropdown menus, and most importantly — automatic collapse to a hamburger menu on mobile screens.2. Learning Objectives
- Build a responsive navbar that collapses on mobile.
- Add brand, links, and a toggler.
- Create dropdown menus in the navbar.
- Implement breadcrumbs and pagination.
- Build a complete responsive navigation system.
3. Basic Navbar Structure
html
4. Navbar Color Options
html
5. Fixed Navbars
html
6. Navbar with User Avatar
html
7. Breadcrumbs
html
8. Pagination
html
9. Common Mistakes
-
Wrong
data-bs-targetvalue: Thedata-bs-target="#mainNav"on the toggler must exactly match theid="mainNav"on the collapse div (including the#).
-
Missing Bootstrap JS for mobile toggle: The hamburger button requires Bootstrap JS (
bootstrap.bundle.min.js). Without it, clicking the toggler does nothing.
10. MCQs
Question 1
What class makes the navbar collapse on mobile?
Question 2
What element creates the hamburger button?
Question 3
What keeps navbar visible while scrolling?
Question 4
What class aligns dropdown to the right?
Question 5
Dropdown trigger uses what attribute?
Question 6
me-auto on <ul class="navbar-nav"> does?
Question 7
Breadcrumb list uses which HTML element?
Question 8
Active pagination item?
Question 9
What class creates a divider inside a dropdown?
Question 10
navbar-expand-lg means the navbar collapses below?
11. Interview Questions
- Q: Explain how Bootstrap's responsive navbar collapse works (the mobile hamburger pattern).
- Q: How do you right-align the user profile dropdown in a navbar?
12. Summary
Bootstrap's navbar component is fully responsive by design — it expands to full navigation on desktop and collapses to a hamburger on mobile through pure HTML data attributes and Bootstrap JS. Thenavbar-expand-{breakpoint} class controls the collapse point. Dropdowns, search forms, and user avatars all integrate seamlessly.