Summarize this article with:
Headers make or break first impressions. A clunky navigation bar sends visitors elsewhere.
These Bootstrap header examples cover the patterns that actually work in production. Fixed navbars, sticky headers, transparent overlays, collapsible mobile menus.
Bootstrap’s navbar component handles the heavy lifting. The framework provides mobile-first design out of the box, cross-browser compatibility, and utility classes for quick customization.
You’ll find code snippets ready to copy. Each example includes the specific CSS classes, breakpoint behavior, and accessibility requirements for real frontend development projects.
Skip the guesswork. Build headers that work on desktop, tablet, and mobile.
What is a Bootstrap Header
A Bootstrap header is a pre-built component in the Bootstrap CSS framework that creates the top section of a webpage.
It contains navigation elements, branding, and user interface controls.
Bootstrap headers use responsive design classes and utility styling to adapt layouts across desktop, tablet, and mobile screen sizes.
The navbar component handles most of the heavy lifting. It combines HTML structure, CSS styling, and JavaScript functionality into a single package.
Bootstrap 5.3 dropped jQuery as a dependency. Earlier versions like Bootstrap 4.6 still require it.
Bootstrap header examples
Avo – Interactive Bootstrap Header With Video Link

Header Blue

Sneaky – Creative Bootstrap Header Design For Restaurant Websites

Sticky Header with Dynamic Height

Bootstrap Static Header

Bootstrap 4 E-Commerce Menu Header Using HTML CSS

Bootstrap Header by Giovanni Rampini

Bootstrap Template Fixed Sidebar And Header

Bootstrap Header Animated

Custom Bootstrap Header by Anton Kastritskiy

Bootstrap 4 Header With Navbar

Niko – Header Design For Present-Day Personal Website

Bootstrap 4 Header With Particles

Bootstrap Video Background Header

Fixed Header on Scroll Bootstrap

What Are the Main Types of Bootstrap Headers
Bootstrap offers several header patterns out of the box. Each serves different design requirements.
Fixed navbar header stays locked at the top of the viewport while users scroll.
Sticky headers start in normal document flow, then stick when reaching a scroll threshold.
Transparent headers overlay content with see-through backgrounds. Popular on landing pages with hero images.
Collapsible headers transform into hamburger menus on smaller screens.
Centered logo headers position branding in the middle with navigation split on both sides.
Off-canvas menu headers slide navigation panels in from the side. Took me a while to get the z-index right on these.
How Does a Fixed Navbar Bootstrap Header Work
The .fixed-top class removes the header from normal document flow and positions it at the viewport top.
Add padding to your body element. Otherwise content hides behind the fixed header.
“ <nav class="navbar navbar-expand-lg fixed-top bg-body-tertiary"> <div class="container-fluid"> <a class="navbar-brand" href="#">Brand</a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"> <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" href="#">Home</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Features</a> </li> </ul> </div> </div> </nav> `
Body Padding Adjustment
Fixed headers cover approximately 56px to 76px of vertical space depending on content.
Set padding-top on the body to match your navbar height.
Use Cases for Fixed Headers
Documentation sites, dashboards, and web applications where constant navigation access matters.
Not ideal for content-heavy blogs. The persistent header eats valuable reading space on mobile.
How Does a Sticky Bootstrap Header Differ from Fixed Headers
Sticky headers use .sticky-top instead of .fixed-top. The behavior difference is significant.
A fixed header removes itself from document flow immediately. It floats above everything from page load.
A sticky header stays in normal position until you scroll past it. Then it sticks to the viewport top.
Technical Comparison
| Property | Fixed Header | Sticky Header | | — | — | — | | CSS Position | position: fixed | position: sticky | | Document Flow | Removed | Preserved until threshold | | Body Padding | Required | Not required | | Browser Support | Universal | IE11 lacks support |
When to Use Sticky Over Fixed
Sticky works better when you want content above the header visible on initial load.
Hero sections, promotional banners, or announcement bars benefit from this approach.
How to Create a Transparent Bootstrap Header
Transparent headers overlay page content. The background shows through the navigation area.
Remove default background classes and set background-color: transparent or use .bg-transparent.
` <nav class="navbar navbar-expand-lg navbar-dark fixed-top"> <div class="container"> <a class="navbar-brand" href="#">Brand</a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#transparentNav"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="transparentNav"> <ul class="navbar-nav ms-auto"> <li class="nav-item"> <a class="nav-link" href="#">About</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Services</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Contact</a> </li> </ul> </div> </div> </nav> `
Text Contrast Considerations
Use .navbar-dark for light text over dark backgrounds. Use .navbar-light for dark text over light images.
Test against your actual hero image. What looks fine in Figma sometimes fails in the browser.
Adding Background on Scroll
Most transparent headers add a solid background after scrolling. This requires JavaScript.
` window.addEventListener('scroll', function() { const navbar = document.querySelector('.navbar'); if (window.scrollY > 50) { navbar.classList.add('bg-dark'); navbar.classList.add('shadow'); } else { navbar.classList.remove('bg-dark'); navbar.classList.remove('shadow'); } }); `
The scroll threshold of 50px works for most layouts. Adjust based on your hero section height.
Chrome, Firefox, Safari, and Edge all handle this consistently. No cross-browser issues to worry about here.
How Does a Collapsible Bootstrap Header Function on Mobile Devices
Collapsible headers transform full navigation into a compact toggle button on smaller screens.
The .navbar-toggler button triggers the collapse. The .navbar-collapse wrapper hides and reveals menu content.
Bootstrap uses media queries to detect screen width and apply the collapse behavior automatically.
` <nav class="navbar navbar-expand-lg bg-body-tertiary"> <div class="container-fluid"> <a class="navbar-brand" href="#">Logo</a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#mainNav" aria-controls="mainNav" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="mainNav"> <ul class="navbar-nav me-auto mb-2 mb-lg-0"> <li class="nav-item"> <a class="nav-link active" href="#">Home</a> </li> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" data-bs-toggle="dropdown">Services</a> <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">Design</a></li> <li><a class="dropdown-item" href="#">Development</a></li> </ul> </li> </ul> </div> </div> </nav> `
Breakpoint Classes
The -expand-{breakpoint} modifier controls when collapse happens: navbar-expand-sm (576px), navbar-expand-md (768px), navbar-expand-lg (992px), navbar-expand-xl (1200px).
Custom Toggle Icons
Replace the default hamburger with Bootstrap icons or SVG graphics for brand consistency.
How to Build a Centered Logo Bootstrap Header
Centered logo headers split navigation links on both sides of the brand element.
The grid system and flexbox utilities handle the layout. No custom CSS required.
` <nav class="navbar navbar-expand-lg bg-light"> <div class="container"> <div class="navbar-collapse collapse w-100 order-1 order-lg-0"> <ul class="navbar-nav me-auto"> <li class="nav-item"> <a class="nav-link" href="#">Home</a> </li> <li class="nav-item"> <a class="nav-link" href="#">About</a> </li> </ul> </div> <div class="mx-auto order-0"> <a class="navbar-brand mx-auto" href="#">BRAND</a> </div> <div class="navbar-collapse collapse w-100 order-3"> <ul class="navbar-nav ms-auto"> <li class="nav-item"> <a class="nav-link" href="#">Services</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Contact</a> </li> </ul> </div> </div> </nav> `
Order Classes for Responsiveness
The .order-{n} classes rearrange elements at different breakpoints, keeping the logo prominent on mobile while maintaining the centered layout on desktop.
What CSS Classes Does Bootstrap Use for Header Components
Bootstrap’s navbar component relies on a specific class structure.
Mix these incorrectly and things break. I learned that the hard way.
Core Navbar Classes
- .navbar
- base wrapper class, required
- .navbar-brand
- logo and site name
- .navbar-nav
- navigation link container
- .nav-item
- individual menu item wrapper
- .nav-link
- clickable link styling
- .navbar-toggler
- mobile collapse button
- .navbar-collapse
- collapsible content wrapper
Color Scheme Classes
- .navbar-light
- dark text for light backgrounds
- .navbar-dark
- light text for dark backgrounds
- .bg-primary
,.bg-dark,.bg-light- background colors
- .bg-body-tertiary
- Bootstrap 5.3 neutral background
Spacing and Alignment
- .me-auto
- push items to the right
- .ms-auto
- push items to the left
- .justify-content-center
- center navigation items
- .container
vs.container-fluid- fixed width vs full width
How to Add a Search Bar to a Bootstrap Header
The Bootstrap form classes integrate search functionality directly into the navbar.
` <form class="d-flex" role="search"> <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search"> <button class="btn btn-outline-success" type="submit"> Search </button> </form> `
Responsive Search Behavior
On mobile, the search form collapses with other navigation items. Use .d-none .d-lg-flex to hide on small screens and show a separate mobile search icon instead.
Search with Icons
Replace the button text with an SVG search icon for cleaner aesthetics, especially in minimalist design layouts.
How to Style Bootstrap Headers with Custom Colors
Override default styles through utility classes or custom CSS variables.
Bootstrap 5 introduced CSS custom properties. Much easier than the Sass approach in Bootstrap 4.
Using Utility Classes
` <nav class="navbar navbar-dark" style="background-color: #7952b3;"> <!-- navbar content --> </nav> `
CSS Variables Method
` .navbar-custom { --bs-navbar-color: rgba(255, 255, 255, 0.85); --bs-navbar-hover-color: rgba(255, 255, 255, 1); --bs-navbar-active-color: #fff; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); } `
Gradient and Pattern Backgrounds
Apply CSS gradients directly or use the CSS Gradient Generator for complex color transitions.
What Accessibility Features Should Bootstrap Headers Include
Web accessibility compliance requires specific attributes on navigation elements.
Screen readers like NVDA and JAWS depend on proper markup to announce header content correctly.
Required ARIA Attributes
- aria-label=”Main navigation”
on the nav element
- aria-expanded=”false”
on toggle buttons
- aria-controls=”navbarId”
linking toggle to collapse target
- aria-current=”page”
on active navigation links
Keyboard Navigation
Users must navigate all menu items using Tab and Enter keys. Bootstrap dropdowns support arrow key navigation by default.
Color Contrast Requirements
WCAG 2.1 requires 4.5:1 color contrast ratio for normal text. Test your header colors with Chrome DevTools accessibility audit.
Which Bootstrap Header Works Best for E-commerce Websites
E-commerce headers need multiple functional elements: search, cart, account, and category navigation.
The mega menu pattern handles large product catalogs. Standard dropdowns feel cramped.
Recommended Structure
- Top bar with contact info, account links
- Main navbar with logo, search bar, cart icon
- Secondary nav for product categories
Cart and Account Integration
Position cart and account icons on the right using .ms-auto. Add badge counters with .badge .rounded-pill for item counts.
Which Bootstrap Header Works Best for Portfolio Sites
Portfolio headers favor minimal navigation with maximum visual impact.
Transparent headers over hero images work well here. Keep navigation links under five items.
Design Considerations
Use .navbar-expand without a breakpoint modifier to keep navigation visible on all screen sizes. Centered or right-aligned layouts complement portfolio aesthetics.
Scroll Behavior Options
Add smooth scroll to anchor links with scroll-behavior: smooth on the html element. Single-page portfolio sites benefit from this user experience improvement.
Common Bootstrap Header Mistakes to Avoid
These issues show up constantly in code reviews and Stack Overflow questions.
Z-Index Conflicts
Fixed headers need z-index: 1030 or higher. Bootstrap modals use 1050, dropdowns use 1000. Overlapping elements cause click issues.
Missing Viewport Meta Tag
Without , responsive breakpoints fail on mobile devices. Always include this in your HTML head.
Incorrect JavaScript Loading
Bootstrap 5 requires Popper.js for dropdowns. Load bootstrap.bundle.min.js instead of bootstrap.min.js to include both.
Forgetting Body Padding
Fixed headers overlay page content. Add padding-top equal to your header height on the body element.
Not Testing Collapse on Touch Devices
Desktop browsers simulate mobile widths but not touch events. Test on actual iPhone and Android devices before launch.
FAQ on Bootstrap Header Examples
How do I make a Bootstrap header responsive?
Use the .navbar-expand-{breakpoint} class to control when the header collapses. Bootstrap applies component classes that automatically adjust layout based on screen width. The toggler button appears on smaller devices while full navigation displays on larger screens.
What is the difference between fixed-top and sticky-top headers?
Fixed-top removes the header from document flow and locks it to the viewport immediately. Sticky-top keeps the header in normal position until scrolling past it. Fixed requires body padding adjustment while sticky does not need this compensation.
How do I add a dropdown menu to a Bootstrap header?
Wrap a .nav-item with .dropdown class. Add data-bs-toggle=”dropdown” to the link and include a .dropdown-menu container with .dropdown-item links inside. Bootstrap 5 handles the toggle behavior through its bundled JavaScript.
Can I use Bootstrap headers without JavaScript?
Basic styling works without JavaScript. Dropdowns and mobile collapse functionality require the Bootstrap JavaScript bundle. For CSS-only alternatives, consider pure CSS dropdown menus or CSS hamburger menus that use checkbox hacks for toggle behavior.
How do I center the logo in a Bootstrap navbar?
Split navigation into two .navbar-collapse sections with .order classes. Place the brand element between them using .mx-auto for horizontal centering. Flexbox utilities handle the equal distribution of menu items on both sides.
What Bootstrap version should I use for headers?
Bootstrap 5.3 is the current stable release. It dropped jQuery dependency and introduced CSS custom properties for easier theming. Bootstrap 4.6 remains viable for projects requiring IE11 support but lacks newer utility classes and components.
How do I change the Bootstrap navbar background color?
Apply background utility classes like .bg-primary or .bg-dark. Custom colors work through inline styles or CSS overrides. Use .navbar-dark for light text on dark backgrounds and .navbar-light for dark text on light backgrounds.
Why is my Bootstrap header not collapsing on mobile?
Check that data-bs-target matches the collapse container ID. Verify Bootstrap JavaScript loads correctly. Missing Popper.js causes dropdown failures. Inspect browser console for errors and confirm the .navbar-expand-{breakpoint} class matches your intended collapse width.
How do I add a search bar to a Bootstrap header?
Insert a form element with .d-flex class inside the navbar. Use Bootstrap input classes on the search field and Bootstrap button styles on the submit element. Position with margin utilities like .ms-auto.
How do I make a Bootstrap header transparent?
Remove background classes and add .bg-transparent or set background-color: transparent in CSS. Combine with .fixed-top to overlay hero content. Add JavaScript to apply a solid background on scroll for better text readability.
Conclusion
These Bootstrap header examples give you production-ready patterns for any project type.
Fixed navbars, sticky headers, transparent overlays, and collapsible menus each solve different design problems. Pick the one that fits your layout requirements.
Remember the fundamentals. Proper ARIA attributes for screen reader support. Correct visual hierarchy in your navigation structure. Body padding for fixed positioning.
Test on actual devices. Chrome DevTools simulation misses touch-specific bugs that show up on real iPhones and Android phones.
The navbar component handles responsive behavior, dropdown menus, and theme customization through Sass variables or CSS custom properties.
Start with the code snippets above. Modify as needed. Ship faster.