Twitter Bootstrap navbar tutorial
Introduction
Using Twitter Bootstrap, you may create static navbar. In this tutorial, you will see how to do that.
Note: An example of Navbar with Twitter Bootstrap 3 is added. You may have a live demo here and may download the zip file containing dist folder downloaded from Bootstrap's website containing css, js and fonts folder and navbar-example.html file. To run it from your own setup without making any changes in the paths, Keep dist folder and the example html file in the same folder.
We will take an HTML5 page with content and see how to add a top navigation bar into it. Here is the final product :

And Here is the HTML5 code of the page without any content.
To create the basic structure to contain the navigations, you may insert the following code right after the <body> tag into the HTML5 code shown above:
Now, let's replace the <!--navigation does here--> with the following code to create the first set of navigations. Note that there is a "brand" class which is rendered in a different way, this may be used to render your company's / organization's name.
Help us to serve you with Better content.
Wish to create a dropdown menu now? For that, you may insert the following code right after the HTML code shown in the last code block.
But, since Twitter Bootstrap Dropdown takes help of JavaScript, so you need to insert following two lines of codes into the HTML page. You may insert them right before the </body> tag.
For inserting a search form into the navbar, right after the <ul> containing the dropdown list, insert the following code. Note that, class "pull-left" is to left align the search form. If you wish to align that right, you may use "pull-right" class.
Now we want to insert social buttons into the navbar. And we want to place it at the right most part of the navbar. We are going to insert Google Plus, Facebook Like, and Tweet buttons. You may insert the following code right after the code for the search form.
class "socials" is not part of the bootstrap.css. Since we want all the social buttons to be aligned center, so we created a little bit of padding around it with it. Here is it:
You may keep that wrapped within <style type="text/css"> and </style>in the page itself or may add it through an external CSS file.
And finally, you need to insert two more blocks of code. One for the Facebook button and another for the Google Plus. These are supplied by the Facebook and Google for inserting buttons dynamically into your page.
So, insert this just after your body tag opens. This is for Facebook
And then this one, just before you body tag closes,for Google Plus
And this is the final code
You may view the example live.
Note that, you need to add a padding of 40px after opening body tag. And add that after the core Bootstrap CSS and before the optional responsive CSS.
Twitter Bootstrap also allows you to create a responsive variation of the navbar. Here is the code:
You may download all the HTML, CSS, JS and image files used in our tutorials here.
Previous: Twitter Bootstrap nav, tabs and pills tutorial
Next:
Twitter Bootstrap inline labels and badges tutorial