Getting Started With Bootstrap: Part 2


I have started an article series. The first part, Getting Started with Bootstrap, provided a basic introduction to Bootstrap and Bootstrap layout.

In this article, we'll learn:

  • Twitter Bootstrap Typography
  • Creating a Simple Table with Twitter Bootstrap
  • Twitter Bootstrap List
  • Create Twitter Bootstrap Forms
  • Twitter Bootstrap Images
  • Twitter Bootstrap Media Objects
  • Twitter Bootstrap Icons
  • Twitter Bootstrap Typography

In this article you we will learn about the styling and text content formatting like headings, paragraphs, blockquotes and so on. It uses Helvetica Neue, Helvetica, Arial and sans-serif in its default font stack.


You can define all the HTML headings, <h1> to <h6>. In the same way you define a simple HTML document. You can also use heading classes .h1 to .h6 on other elements, if you want to apply a heading style on other elements.


  1. <h1>h1: Getting started with Bootstrap</h1>   
  2. <h2>h2: Getting started with Bootstrap</h2>   
  3. <h3>h3: Getting started with Bootstrap</h3>   
  4. <h4>h4: Getting started with Bootstrap</h4>   
  5. <h5>h5: Getting started with Bootstrap</h5>   
  6. <h6>h6: Getting started with Bootstrap</h6>   


You can use the <small> and <span> tags with .small class to display the secondary text of any heading in a smaller and lighter variation. 

HTML Code 
  1. <h1>h1: Getting started with Bootstrap<small>MCN Solutions</small></h1>   
  2. <h2>h2: Getting started with Bootstrap<small>MCN Solutions</small></h2>   
  3. <h3>h3: Getting started with Bootstrap<small>MCN Solutions</small></h3>   
  4. <h4>h4: Getting started with Bootstrap<small>MCN Solutions</small></h4>   
  5. <h5>h5: Getting started with Bootstrap<small>MCN Solutions</small></h5>   
  6. <h6>h6: Getting started with Bootstrap<small>MCN Solutions</small></h6>   

Bootstrap defines the global style for all paragraphs with default font-size 14px. You can add a .lead class to make a paragraph stand out.
  1. <p>This is how a normal paragraph looks like in Twitter Bootstrap.</p>   
  2. <p class="lead">This is how a paragraph stands out in Twitter Bootstrap.</p>   


In bootstrap you can easily align text inside the paragraph using the text-alignment classes.
 HTML code 
  1. <p class="text-left"> Align Left Text </p>   
  2. <p class="text-center"> Align Center Text </p>   
  3. <p class="text-right"> Align Right Text </p>   
  4. <p class="text-justify"> Justify Text </p>   
  5. <p class="text-nowrap"> no wrap Text </p>   

Text Formatting
You can use HTML text formating tags like <strong>,<i><small> to make your text bold, italic, small and so on.
HTML Code 
  1. <p><b>This is bold text</b></p>   
  2. <p><big>This is big text</big></p>   
  3. <p><code>This is computer code</code></p>   
  4. <p><em>This is emphasized text</em></p>   
  5. <p><i>This is italic text</i></p>   
  6. <p><mark>This is highlighted text</mark></p>   
  7. <p><small>This is small text</small></p>   
  8. <p><strong>This is strongly emphasized text</strong></p>   
  9. <p>This is <sub>subscript</sub> and <sup>superscript</sup></p>   
  10. <p><ins>This text is inserted to the document</ins></p>   
  11. <p><del>This text is deleted from the document</del></p>   

Text Transformation Classes
You can also transform the text to lowercase, uppercase or make them capitalized. 
  1. <p class="text-uppercase">C# Corner is social community for developer</p>   
  2. <p class="text-lowercase">C# Corner is social community for developer</p>   
  3. <p class="text-capitalize">C# Corner is social community for developer</p>  

Text Emphasis classes

Colors are the powerful method of conveying important information in website design. Bootstrap provides emphasis utility classes that can be used for showing success message in Green, warning or error message in Red, and so on.
HTML Code 
  1. <p class="text-muted">Muted: This text is grayed out.</p>   
  2. <p class="text-primary">Important: Please read the instructions carefully before proceed.</p>   
  3. <p class="text-success">Success: Your message has been sent successfully.</p>   
  4. <p class="text-info">Note: You must agree with the terms and conditions to complete the sign up process.</p>   
  5. <p class="text-warning">Warning: There was a problem with your network connection.</p>   
  6. <p class="text-danger">Error: An error has been occurred while submitting your data.</p>   

Bootstrap provides styling of blockquotes. You just define the blockquotes using the standard element <blockquote>.
HTML Code 
  1. <blockquote>   
  2.     <p>Success is blocked by concentrating on it and planning for it... Success is shy - it won't come out while you're watching.</p>   
  3.     <small>by <cite>Tennessee Williams</cite></small>   
  4. </blockquote>   

Creating a Simple Table with Twitter Bootstrap
The following explains tables and how to create a table using Bootstrap. HTML tables are used to present data in a grid manner like rows and columns. You can create tables with basic styling that has horizontal dividers and small cell padding (8px by default), by just adding the Bootstrap's class .table to the <table> element.
HTML Code 
  1. <table class="table">   
  2.      <thead>   
  3.          <tr>   
  4.              <th>Row</th>   
  5.              <th>First Name</th>   
  6.              <th>Last Name</th>   
  7.              <th>Email</th>   
  8.          </tr>   
  9.      </thead>   
  10.      <tbody>   
  11.          <tr>   
  12.              <td>1</td>   
  13.              <td>Vipin</td>   
  14.              <td>Choudhary</td>   
  15.              <td>[email protected]</td>   
  16.          </tr>   
  17.          <tr>   
  18.              <td>2</td>   
  19.              <td>Manoj</td>   
  20.              <td>Dhakar</td>   
  21.              <td>[email protected]</td>   
  22.          </tr>   
  23.          <tr>   
  24.              <td>3</td>   
  25.              <td>Vikas</td>   
  26.              <td>Sharma</td>   
  27.              <td>[email protected]</td>   
  28.          </tr>   
  29.      </tbody>   
  30.  </table>   

Use Contextual classes in Bootstrap Table
The contextual classes shown in the following table will allow you to change the background color of your table rows or individual cells.

Class Description
.active Applies the hover color to a specific row or cell
.success Indicates a successful or positive action
.warning Indicates a warning that might need attention
.danger Indicates a dangerous or potentially negative action

These classes can be applied to <tr>, <td> or <th> .
  1. <table class="table">   
  2.     <thead>   
  3.         <tr>   
  4.             <th>Row</th>   
  5.             <th>First Name</th>   
  6.             <th>Last Name</th>   
  7.             <th>Email</th>   
  8.         </tr>   
  9.     </thead>   
  10.     <tbody>   
  11.         <tr class="active">   
  12.             <td>1</td>   
  13.             <td>Vipin</td>   
  14.             <td>Choudhary</td>   
  15.             <td>[email protected]</td>   
  16.         </tr>   
  17.         <tr class="success">   
  18.             <td>2</td>   
  19.             <td>Manoj</td>   
  20.             <td>Dhakar</td>   
  21.             <td>[email protected]</td>   
  22.         </tr>   
  23.         <tr class="warning">   
  24.             <td>3</td>   
  25.             <td>Vikas</td>   
  26.             <td>Sharma</td>   
  27.             <td>[email protected]</td>   
  28.         </tr>   
  29.         <tr class="danger">   
  30.             <td>4</td>   
  31.             <td>Deepak</td>   
  32.             <td>Verma</td>   
  33.             <td>[email protected]</td>   
  34.         </tr>   
  35.     </tbody>   
  36. </table>   

You can create a stylish and colorful border table by simple adding the Bootstrap's class in the <table> tag with the .table class. Some of Bootstrap's table class are:

  • .table-striped: Use for Alternate background of table row.
  • .table-bordered: Use for adding the border to all cells in table.
  • .table-hover: Use for enable the hover state on table rows.
  • .table-condensed: Makes the table compact by cutting the cell padding in half.

Twitter Bootstrap List

In this you will learn how to create a styling list in bootstrap. The following are three types of list:

  • Unordered lists: An unordered list is simply a list of related items whose order does not matter. An unordered list is a list that doesn't have any specific order and is traditionally styled with bullets.
  • Ordered lists: A list of items in which the order does explicitly matter. An ordered list is a list that falls in some sort of sequential order and is prefaced by numbers.
  • Definition list: A list of terms with their associated descriptions. In this type of list, each list item can consist of both the <dt> and the <dd> elements. <dt> stands for definition term and like a dictionary, this is the term (or phrase) that is being defined. Subsequently, the <dd> is the definition of the <dt>. You can make terms and descriptions in <dl> line up side-by-side using class dl-horizontal.

UnStyled Ordered and Unordered Lists

In bootstrap you can remove the style from the list items. You can do this by applying the class .list-unstyled to the respective <ul> or <ol> elements.


  1. <ul class="list-unstyled">   
  2.     <li>Home</li>   
  3.     <li>Technologies   
  4.         <ul>   
  5.             <li>HTML5</li>   
  6.             <li>CSS3</li>   
  7.             <li>Bootstrap</li>   
  8.         </ul>   
  9.     </li>   
  10.     <li>Answers</li>   
  11.     <li>Blog</li>   
  12. </ul>   

Note: If you removed .list-unstyled then list-style are the default and the left padding is only from the list items that are immediate children of the <ul> or <ol>element.

Styled Ordered and Unordered Lists with Bootstrap

Twitter Bootstrap provide various list-style class for different style. These are given below:

  • .list-inline: Use for create horizontal menu using ordered or unordered list you need to place all list items in a single line, in other words side by side.
  • .dl-horizontal: Use for create descriptions in definition lists can also be placed side-by-side.
  • .list-group: Use for a component for displaying lists of items in a beautiful manner. In the most basic form a list group is simply an unordered list with list items and proper classes.


For list inline styles:

  1. <ul class="list-inline">   
  2.     <li>Home</li>   
  3.     <li>Technologies</li>   
  4.     <li>Answer</li>   
  5.     <li>Blog</li>   
  6. </ul>   
For a description list:
  1. <dl class="dl-horizontal">   
  2.     <dt>Technologies</dt>   
  3.         <dd>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec quis risus quis ante elementum volutpat vel quis nisi. Mauris vehicula eros vitae tincidunt venenatis.</dd>   
  4.     <dt>Aricle</dt>   
  5.         <dd>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec quis risus quis ante elementum volutpat vel quis nisi.</dd>   
  6.     <dt>Blog</dt>   
  7.         <dd>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec quis risus quis ante elementum volutpat vel quis nisi. Mauris vehicula eros vitae tincidunt venenatis.</dd>   
  8. </dl>  
For a group list:
  1. <ul class="list-group">   
  2.     <li class="list-group-item">Home</li>   
  3.     <li class="list-group-item">Technologies</li>   
  4.     <li class="list-group-item">Answer</li>   
  5.     <li class="list-group-item">Blog</li>   
  6. </ul>   

Create Twitter Bootstrap Forms

The following explains how to create forms using Twitter bootstrap.

HTML forms are the integral part of the web pages, but the styling the form controls manually one by one using CSS can be a tedious process. Twitter Bootstrap simplifies the styling process of form controls like input-boxes, select-boxes, textareas, and so on.

Twitter Bootstrap provides the following three types of form layouts:

  • Vertical Form
  • Horizontal Form
  • Inline Form

Creating Vertical Form Layout

A Vertical Form layout is the default layout form of bootstrap in which styles are applied to form controls without adding any base class to the <form > element. The form controls in this layout are stacked with left-aligned labels on the top. The class .form-control makes all textual elements like <input>, <textarea> and <select> are 100% wide by default. To use them inline, you will need to set a width on the element the form controls used within. To create a basic form do the following:

Add a role form to the parent <form> element.

Wrap labels and controls in a <div> with class the .form-group. This is needed for optimum spacing.

Add a class of .form-control to all textual <input>, <textarea>, and <select> elements.


  1. <form>   
  2.    <div class="form-group">   
  3.        <label for="inputEmail">Email</label>   
  4.        <input type="email" class="form-control" id="inputEmail" placeholder="Email">   
  5.    </div>   
  6.    <div class="form-group">   
  7.        <label for="inputPassword">Password</label>   
  8.        <input type="password" class="form-control" id="inputPassword" placeholder="Password">   
  9.    </div>   
  10.    <div class="checkbox">   
  11.        <label><input type="checkbox"> Remember me</label>   
  12.    </div>   
  13.    <button type="submit" class="btn btn-primary">Login</button>   
  14. </form>   

Creating Horizontal Form Layout

In a horizontal form layout labels are right-aligned and floated to left to make them appear on the same line as form controls. The horizontal form layout requires the various markup changes from a default form layout. The procedure is listed below.
In the form element, add the class .form-horizontal.
Wrap labels and form controls in <div> elements and apply the class .form-group on the <div> element.
Add the class .control-label to the <label> element.
<input>, <select>, and <textarea> elements in a <div> element.
Use Bootstrap's predefined grid classes to align labels and and form controls parent <div> element.
Add the class .control-label to the <label> element.
Add the class .form-control to the <input>,<select>, and <textarea> elements.
HTML Code 
  1. <form class="form-horizontal">   
  2.      <div class="form-group">   
  3.          <label for="inputEmail" class="control-label col-xs-2">Email</label>   
  4.          <div class="col-xs-10">   
  5.              <input type="email" class="form-control" id="inputEmail" placeholder="Email">   
  6.          </div>   
  7.      </div>   
  8.      <div class="form-group">   
  9.          <label for="inputPassword" class="control-label col-xs-2">Password</label>   
  10.          <div class="col-xs-10">   
  11.              <input type="password" class="form-control" id="inputPassword" placeholder="Password">   
  12.          </div>   
  13.      </div>   
  14.      <div class="form-group">   
  15.          <div class="col-xs-offset-2 col-xs-10">   
  16.              <div class="checkbox">   
  17.                  <label><input type="checkbox"> Remember me</label>   
  18.              </div>   
  19.          </div>   
  20.      </div>   
  21.      <div class="form-group">   
  22.          <div class="col-xs-offset-2 col-xs-10">   
  23.              <button type="submit" class="btn btn-primary">Login</button>   
  24.          </div>   
  25.      </div>   
  26.  </form>   

Static Form Control

There might be a situation when you need to place just plain text next to a form lable instead of a form control. You can do this within a horizontal form layout by using the .form-control-static class on a <p> element, like this: 
  1. <div class="form-group">   
  2.      <label for="inputEmail" class="control-label col-xs-2">Email</label>   
  3.      <div class="col-xs-10">   
  4.          <p class="form-control-static">[email protected]</p>   
  5.      </div>   
  6.  </div>   
Creating Inline Form Layout
Sometimes you need to place the form controls side-by-side to compact the layout. You can do this by adding the Bootstrap class .form-inline to the <form> element. In an Inline form layout, you need to include a label for every form input otherwise screen readers will have trouble with your forms. However in the case of an inline form layout you can hide these labels using the .sr-only class.
HTML Code 
  1. <form class="form-inline">   
  2.     <div class="form-group">   
  3.         <label class="sr-only" for="inputEmail">Email</label>   
  4.         <input type="email" class="form-control" id="inputEmail" placeholder="Email">   
  5.     </div>   
  6.     <div class="form-group">   
  7.         <label class="sr-only" for="inputPassword">Password</label>   
  8.         <input type="password" class="form-control" id="inputPassword" placeholder="Password">   
  9.     </div>   
  10.     <div class="checkbox">   
  11.         <label><input type="checkbox"> Remember me</label>   
  12.     </div>   
  13.     <button type="submit" class="btn btn-primary">Login</button>   
  14. </form>   

Height sizing of Inputs and Select Boxes

With Bootstrap, you can easily control the height of your input and select boxes to match the button sizes. The Bootstrap's relative sizing classes like .input-lg, .input-sm can be used both on <input> and <select> boxes to create it's larger or smaller sizes.


  1. <form>   
  2.     <div class="row">   
  3.         <div class="col-xs-6">   
  4.             <input type="text" class="form-control input-lg" placeholder="Larger input">   
  5.         </div>   
  6.         <div class="col-xs-6">   
  7.             <select class="form-control input-lg">   
  8.                 <option>Larger select</option>   
  9.             </select>   
  10.         </div>   
  11.     </div>   
  12.     <br>   
  13.     <div class="row">   
  14.         <div class="col-xs-6">   
  15.             <input type="text" class="form-control" placeholder="Default input">   
  16.         </div>   
  17.         <div class="col-xs-6">   
  18.             <select class="form-control">   
  19.                     <option>Default select</option>   
  20.             </select>   
  21.         </div>   
  22.     </div>   
  23.     <br>   
  24.     <div class="row">   
  25.         <div class="col-xs-6">   
  26.             <input type="text" class="form-control input-sm" placeholder="Smaller input">   
  27.         </div>   
  28.         <div class="col-xs-6">   
  29.             <select class="form-control input-sm">   
  30.                 <option>Smaller select</option>   
  31.             </select>   
  32.         </div>   
  33.     </div>   
  34. </form>   


Validation States with Twitter Bootstrap

Bootstrap provides an easy to use and powerful mechanism for styling input controls to present various validation states. Bootstrap includes validation styles for error, warning and success messages. To use, just add the appropriate class to the surrounding .form-group.
The following shows Twitter Bootstrap Form Validation States.
  1. <form class="form-horizontal">   
  2.     <div class="form-group has-success">   
  3.         <label class="col-xs-2 control-label" for="inputSuccess">Username</label>   
  4.         <div class="col-xs-10">   
  5.             <input type="text" id="inputSuccess" class="form-control" placeholder="Input with success">   
  6.             <span class="help-block">Username is available</span>   
  7.         </div>   
  8.     </div>   
  9.     <div class="form-group has-warning">   
  10.         <label class="col-xs-2 control-label" for="inputWarning">Password</label>   
  11.         <div class="col-xs-10">   
  12.             <input type="password" id="inputWarning" class="form-control" placeholder="Input with warning">   
  13.             <span class="help-block">Password strength: Weak</span>   
  14.         </div>   
  15.     </div>   
  16.     <div class="form-group has-error">   
  17.         <label class="col-xs-2 control-label" for="inputError">Email</label>   
  18.         <div class="col-xs-10">   
  19.             <input type="email" id="inputError" class="form-control" placeholder="Input with error">   
  20.             <span class="help-block">Please enter a valid email address</span>   
  21.         </div>   
  22.     </div>   
  23. </form>   

Twitter Bootstrap Images

The following explains how to style images, creating thumbnails, grid of images, videos, text and so on.

We can use images to create a modern web page design. So styling images and placing them properly on web pages. Bootstrap provides the predifined classes for styling images. These are :

  • .img-rounded: It is making the round cornered images.
  • .img-circle: It is making the circular images.
  • .img-thumbnail: It is provide the effect like thumbnail.


  1. <img src="image.png" class="img-rounded" >   
  2. <img src="image.png" class="img-circle" >   
  3. <img src="image.png" class="img-thumbnail" >   

Twitter Bootstrap Thumbnails

The Twitter Bootstrap thumbnails component is very useful for creating grids of images or videos, list of products, portfolios and much more. See the HTML for thumbnails grid of images.
  1. <div class="container">   
  2.     <div class="row">   
  3.         <div class="col-xs-2">   
  4.             <a href="#" class="thumbnail">   
  5.                 <img src="image.png" >   
  6.             </a>   
  7.         </div>   
  8.         <div class="col-xs-2">   
  9.             <a href="#" class="thumbnail">   
  10.                 <img src="image.png" >   
  11.             </a>   
  12.         </div>   
  13.         <div class="col-xs-2">   
  14.             <a href="#" class="thumbnail">   
  15.                 <img src="image.png" >   
  16.             </a>   
  17.         </div>   
  18.         <div class="col-xs-2">   
  19.             <a href="#" class="thumbnail">   
  20.                 <img src="image.png" >   
  21.             </a>   
  22.         </div>   
  23.         <div class="col-xs-2">   
  24.             <a href="#" class="thumbnail">   
  25.                 <img src="image.png" >   
  26.             </a>   
  27.         </div>   
  28.         <div class="col-xs-2">   
  29.             <a href="#" class="thumbnail">   
  30.                 <img src="image.png" >   
  31.             </a>   
  32.         </div>   
  33.     </div>   
  34. </div>  

Twitter Bootstrap Media Objects

If you want to create a layout like blog comments that contains a left- or right-aligned image along with the textual content, you can do that easily through the newly introduced Bootstrap media component, like this.
HTML Code 

  1. <div class="media">   
  2.      <a href="#" class="pull-left">   
  3.          <img src="image.png" class="media-object">   
  4.      </a>   
  5.      <div class="media-body">   
  6.          <h4 class="media-heading">Vipin Kumar <small><i>Posted on September 02, 2014</i></small></h4>   
  7.          <p> The first part Getting started with Bootstrap provided a basic introduction of bootstrap and bootstrap layout.</p>   
  8.      </div>   
  9. </div>   


Note: You can also create a list of media objects or nested media objects using the media list component. It can be useful for comment threads or article lists.
Twitter Bootstrap Icons
This explains how to use Twitter Bootstrap Icons. Twitter Bootstrap includes 200 Glyphicons. These icons are available in font format for better usability and scalability. To use the Bootstrap icons you will require a <span>, <i> ,<a> and so on. tag along with a base class .glyphicon and individual icon class .glyphicon-*. The general syntax for using Bootstrap icons is: 
  1. <span class="glyphicon glyphicon-class-name"></span>   
Note: If you want to use your own font format icon you can learn here.