Bootstrap Navigation
Introduction
In this tutorial, you will learn how to use the Bootstrap toolkit to create navigation with navs, tabs, and pills.
We have demonstration examples with explanations, including: basic tab-based and pill-based navigation, stacked (vertical) tab-based and pill-based navigation, tab-based and pill-based dropdown menus, creating stacked navigation with nav lists, and creating clickable navigation with JavaScript (in different orientations).
Basic Tabs
Two CSS classes, .nav and .nav-tabs, are used to create basic tab-based navigation. In Bootstrap version v2.0.1, the styles for the .nav class are declared on lines 2176 to 2220 (some related styles are included here). Lines 2222 to 2267 contain the styles for .nav-tabs. The following example shows how to create basic tab-based navigation with Bootstrap.
Bootstrap basic tab-based navigation example
Example
Output

View online
View the example above in different browser windows.
Basic Pills
Once you know how to create basic tab-based navigation with Bootstrap, creating basic pill-based navigation is easy. Instead of the .nav-tabs class, use the .nav-pills class. The styles for .nav-pills are on lines 2222 to 2224 in bootstrap.css, and are repeated on lines 2268 to 2280 in bootstrap.css (used in the last example).
The following example shows how to create basic pill-based navigation.
Bootstrap basic pill-based navigation example
Example
Output

View online
View the example above in different browser windows.
Stacked or Vertical Tabs
To create stacked or vertical tab-based navigation, you must add the .nav-stacked, .nav, and .nav-tabs classes to your markup; by default, horizontal tab-based navigation is created. Lines 2281 to 2309 contain the styles for .nav-stacked. Here is an example.
Bootstrap stacked or vertical tab-based navigation example
Example
Output

View online
View the example above in different browser windows.
Stacked or Vertical Pills
Similar to creating stacked or vertical tabs, you need an additional CSS class to create stacked or vertical pill-based navigation. That is the .nav-stacked class, located at lines 2281 to 2309, which contains the styles for .nav-stacked. Here is an example.
Bootstrap stacked or vertical pill-based navigation example
Example
Output

View online
View the example above in different browser windows.
Tab-based Dropdown Menus
You can use Bootstrap to create tab-based dropdown menu navigation. There are four CSS classes you need - .dropdown, .dropdown-toggle, .dropdown-menu, and .caret - as well as the .nav and .nav-tabs classes. In bootstrap.css (version 2.0.1), lines 1545 to 1547 contain the styles for the .dropdown class, lines 1548 to 1553 contain the styles for .dropdown-toggle, lines 1576 to 1632 contain the styles for .dropdown-menu, and lines 1554 to 1575 contain the styles for .caret. Another CSS class, .divider, is also used in the demo example, but it is not required.
Of course, you need to reference three JavaScript files in your HTML file - jquery.js, bootstrap-dropdown.js, and application.js. All of these are located in the docs/assets/js/ folder.
Here is an example.
Bootstrap tab-based dropdown menu navigation example
Example
.container {
margin-top: 200px;
}
Note: We added a separate style tag and referenced it in a small set of styles to create a 200-pixel top margin for the container; this is just for demonstration. data-toggle is a Bootstrap-specific attribute. Setting its value to "dropdown" creates a dropdown menu navigation.
Output
Tab-based dropdown menu:

Tab-based dropup menu:

View online
View the example above in different browser windows.
Pill-based Dropdown Menus
The markup and CSS for creating pill-based dropdown menus are similar to those for tab-based dropdown menus. The only thing to do is replace the .nav-tabs class with .nav-pills. Here is an example.
Bootstrap pill-based dropdown menu navigation example
Example
.container {
margin-top: 200px;
}
Output
Pill-based dropdown menu:

Pill-based dropup menu:

View online
View the example above in different browser windows.
Creating Stacked Navigation with Optional Headers Using Nav Lists
.nav-class can be used to create stacked navigation suitable for a sidebar. You can add headers to a group of links, defining styles for .nav-list located at lines 2201 to 2221 in bootstrap.css (version 2.0.1). Here is an example.
Stacked navigation example with nav lists
Example
Output
View online
View the example above in different browser windows.
Creating Stacked Navigation with Icons Using Nav Lists
Example
Output
![]()
View online
View the example above in different browser windows.
Creating Clickable Navigation with JavaScript
You can create tabbed navigation with Bootstrap's lightweight jQuery plugin and simple markup.
How to Create Clickable Navigation?
You need a CSS class named "tabbable" to act as a wrapper. Inside it, add the "nav" and "nav-tabs" classes to a "ul" element. Inside that, use 'data-toggle="tab"' (applied to the relevant anchor elements) to create the clickable areas. Then, create a div with the CSS class "tab-content", which contains divs with the CSS class "tab-pane" to hold the actual content.
For the clickable navigation to work properly, you need to reference two JS files - jquery.js and bootstrap-tab.js. Both files are located in the docs/assets/js folder.
Here is an example demonstrating clickable navigation.
Example
You are watching section 1.
You are watching Section 2.
You are watching Section 3.
Click here to download all the HTML, CSS, JS, and image files used in this tutorial.