I have started an article series on Bootstrap and published four articles so far. Read the previous four parts here.
Introduction
In this article we will learn about Bootstrap Tables. Using Bootstrap classes we can improve the appearance of the table. In this article we will create different tables with different layouts.
Supported Table Elements
The following table elements are used with Bootstrap:
In this article we will learn about Bootstrap Tables. Using Bootstrap classes we can improve the appearance of the table. In this article we will create different tables with different layouts.
Supported Table Elements
The following table elements are used with Bootstrap:
- <table>: It is used for wrapping element for displaying data in a tabular format
- <thead>: It is used for container element for table header rows (<tr>) to label table columns.
- <tbody>: It is used for container element for table rows (<tr>) in the body of the table.
- <tr>: It is used for container element for a set of table cells (<td> or <th>) that appears on a single row.
- <th>: Special table cell for column (or row) labels. it must be used within a <thead>
- <td>: It is used for default table cell.
- <caption>: It is used for description or summary of what the table holds.
Bootstrap Basic Table
We can create a basic Bootstrap table with basic styling that has a small cell padding and only horizontal dividers by adding Bootstrap class ".table" to the <table> element.
Example 1 : Bootstrap Basic Table using .table class.
In this example we will create a simple table with Bootstrap class and using html table elements we will create a employee table with Fields Sr. No., Employee Name, Email, City by writing the following code.
We can create a basic Bootstrap table with basic styling that has a small cell padding and only horizontal dividers by adding Bootstrap class ".table" to the <table> element.
Example 1 : Bootstrap Basic Table using .table class.
In this example we will create a simple table with Bootstrap class and using html table elements we will create a employee table with Fields Sr. No., Employee Name, Email, City by writing the following code.
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Bootstrap Part5</title>
- <meta name="viewport" content="width=device-width,initial-scale=1">
- <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
- </head>
- <body>
- <div class="container">
- <h1>Bootstrap Basic Table</h1>
- <!--Bootstrap Basic Table using .table class-->
- <table class="table">
- <thead>
- <tr>
- <th>Sr.No.</th>
- <th>Emolpyee Name</th>
- <th>Email</th>
- <th>City</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>1</td>
- <td>Shaili Dashora</td>
- <td>[email protected] </td>
- <td>Chittorgarh</td>
- </tr>
- <tr>
- <td>2</td>
- <td>Sourabh Somani</td>
- <td>[email protected] </td>
- <td>Banglore</td>
- </tr>
- <tr>
- <td>3</td>
- <td>Shobhna Singvi</td>
- <td>[email protected]</td>
- <td>Mumbai</td>
- </tr>
- </tbody>
- </table>
- </div>
- <script src="js/jquery-2.1.4.min.js"></script>
- <script src="js/bootstrap.min.js"></script>
- </body>
- </html>
Output: Basic Table Layout

Table with Striped Rows
By using .table-striped class with .table base class, we can get zebra-stripes on rows to a table within <tbody>.
Example 2 : Table with Striped Rows Using .table-striped class
In this example we will create table same as Example1. In this we will create table with Striped Rows by writing the following code.

Table with Striped Rows
By using .table-striped class with .table base class, we can get zebra-stripes on rows to a table within <tbody>.
Example 2 : Table with Striped Rows Using .table-striped class
In this example we will create table same as Example1. In this we will create table with Striped Rows by writing the following code.
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Bootstrap Part5</title>
- <meta name="viewport" content="width=device-width,initial-scale=1">
- <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
- </head>
- <body>
- <div class="container">
- <h1>Bootstrap Table With Striped Rows</h1>
- <!--Bootstrap Table using .table-striped class-->
- <table class="table table-striped">
- <thead>
- <tr>
- <th>Sr.No.</th>
- <th>Emolpyee Name</th>
- <th>Email</th>
- <th>City</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>1</td>
- <td>Shaili Dashora</td>
- <td>[email protected] </td>
- <td>Chittorgarh</td>
- </tr>
- <tr>
- <td>2</td>
- <td>Sourabh Somani</td>
- <td>[email protected] </td>
- <td>Banglore</td>
- </tr>
- <tr>
- <td>3</td>
- <td>Shobhna Singvi</td>
- <td>[email protected]</td>
- <td>Mumbai</td>
- </tr>
- </tbody>
- </table>
- </div>
- <script src="js/jquery-2.1.4.min.js"></script>
- <script src="js/bootstrap.min.js"></script>
- </body>
- </html>
Output: Striped Table Layout

Bordered Table
The .table-bordered class adds borders on all sides of the table and cells.
Example 3: Table with Borders on All Sides Using .table-bordered class
In this example we will creat a table same as Example 1, 2. In this we will create a table with borders on all sides of the table and cells by using .table-bordered class with .table base class by writing the following code.

Bordered Table
The .table-bordered class adds borders on all sides of the table and cells.
Example 3: Table with Borders on All Sides Using .table-bordered class
In this example we will creat a table same as Example 1, 2. In this we will create a table with borders on all sides of the table and cells by using .table-bordered class with .table base class by writing the following code.
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Bootstrap Part5</title>
- <meta name="viewport" content="width=device-width,initial-scale=1">
- <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
- </head>
- <body>
- <div class="container">
- <h1>Bootstrap Bordered Table</h1>
- <!--Bootstrap Table using .table-bordered class-->
- <table class="table table-bordered">
- <thead>
- <tr>
- <th>Sr.No.</th>
- <th>Emolpyee Name</th>
- <th>Email</th>
- <th>City</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>1</td>
- <td>Shaili Dashora</td>
- <td>[email protected] </td>
- <td>Chittorgarh</td>
- </tr>
- <tr>
- <td>2</td>
- <td>Sourabh Somani</td>
- <td>[email protected] </td>
- <td>Banglore</td>
- </tr>
- <tr>
- <td>3</td>
- <td>Shobhna Singvi</td>
- <td>[email protected]</td>
- <td>Mumbai</td>
- </tr>
- </tbody>
- </table>
- </div>
- <script src="js/jquery-2.1.4.min.js"></script>
- <script src="js/bootstrap.min.js"></script>
- </body>
- </html>






Prasanna MuraliPosted May 20, 2016, 11:17 AM
Nice one....
Sonu ChaudharyPosted May 2, 2016, 6:01 AM
Thanks for sharing
Vivek KumarPosted Apr 28, 2016, 3:02 PM
Good one
Debasis SahaPosted Apr 11, 2016, 10:35 AM
Nice One...
Humayun Kabir MamunPosted Apr 10, 2016, 11:40 PM
Nice...
Michael GriffithsPosted Apr 10, 2016, 2:38 PM
thanks for sharing buddy :)
NitinPosted Apr 10, 2016, 1:22 AM
Good one
Sourabh SomaniPosted Apr 9, 2016, 12:59 PM
Good Going Keep it up :)
Rahul Kumar SaxenaPosted Apr 9, 2016, 12:26 PM
Hi 5 Bootstrap... Good Work
Vignesh ManiPosted Apr 9, 2016, 11:17 AM
Good one
Gowtham KPosted Apr 9, 2016, 10:25 AM
Nice share:)
Kuppurasu NagarajPosted Apr 9, 2016, 10:23 AM
Nice article..
Gowtham RajamanickamPosted Apr 9, 2016, 9:31 AM
Easy to learn..
Gowtham RajamanickamPosted Apr 9, 2016, 9:30 AM
Very good article