Navs
Documentation and examples for how to use Bootstrap’s included navigation components.
Available styles
Change the style of .nav
s component with modifiers and utilities. Mix and match as needed, or build your own.
Horizontal alignment
Change the horizontal alignment of your nav with flexbox utilities . By default, navs are left-aligned, but you can easily change them to center or right aligned.
Centered with .justify-content-center
:
Right-aligned with .justify-content-end
:
Vertical
Stack your navigation by changing the flex item direction with the .flex-column
utility. Need to stack them on some viewports but not others? Use the responsive versions (e.g., .flex-sm-column
).
As always, vertical navigation is possible without <ul>
s, too.
Classic
Take that same HTML, but use .nav-classic
instead:
Disable the border wrapper with .nav-borderless
class:
Fill and justify
Force your .nav
’s contents to extend the full available width one of two modifier classes. To proportionately fill all available space with your .nav-item
s, use .nav-fill
. Notice that all horizontal space is occupied, but not every nav item has the same width.
When using a <nav>
-based navigation, be sure to include .nav-item
on the anchors.
For equal-width elements, use .nav-justified
. All horizontal space will be occupied by nav links, but unlike the .nav-fill
above, every nav item will be the same width.
Similar to the .nav-fill
example using a <nav>
-based navigation, be sure to include .nav-item
on the anchors.
Working with flex utilities
If you need responsive nav variations, consider using a series of flexbox utilities . While more verbose, these utilities offer greater customization across responsive breakpoints. In the example below, our nav will be stacked on the lowest breakpoint, then adapt to a horizontal layout that fills the available width starting from the small breakpoint.
Regarding accessibility
If you’re using navs to provide a navigation bar, be sure to add a role="navigation"
to the most logical parent container of the <ul>
, or wrap a <nav>
element around the whole navigation. Do not add the role to the <ul>
itself, as this would prevent it from being announced as an actual list by assistive technologies.
Note that navigation bars, even if visually styled as tabs with the .nav-tabs
class, should not be given role="tablist"
, role="tab"
or role="tabpanel"
attributes. These are only appropriate for dynamic tabbed interfaces, as described in the WAI ARIA Authoring Practices .