Bootstrap Tables
Bootstrap has some classes for <table> tag. The classes can be used for styling tables. they are following:
- table
- table-striped
- table-bordered
- table-hover
- table-condensed
Bootstrap table Class
you can use table class for creating a simple table.
Example:
<table class="table">
<tr>
<th> Name </th>
<th> Id </th>
</tr>
<tr>
<td> John </td>
<td> 53 </td>
</tr>
<tr>
<td> Mike </td>
<td> 54 </td>
</tr>
</table>
<tr>
<th> Name </th>
<th> Id </th>
</tr>
<tr>
<td> John </td>
<td> 53 </td>
</tr>
<tr>
<td> Mike </td>
<td> 54 </td>
</tr>
</table>
Run Example
Bootstrap table-striped Class
you can use table-striped class for creating a zebra-striped table.
Example:
<table class="table table-striped">
<tr>
<th> Name </th>
<th> Mail </th>
<th> Address </th>
</tr>
<tr>
<td> Jack </td>
<td> jack@gmail.com </td>
<td> London </td>
</tr>
</table>
<tr>
<th> Name </th>
<th> Mail </th>
<th> Address </th>
</tr>
<tr>
<td> Jack </td>
<td> jack@gmail.com </td>
<td> London </td>
</tr>
</table>
Run Example
Bootstrap table-bordered Class
you can use table-bordered class for creating a bordered table.
Example:
<table class="table table-bordered">
<tr>
<th> Name </th>
<th> Mail </th>
<th> Address </th>
</tr>
<tr>
<td> Jack </td>
<td> jack@gmail.com </td>
<td> London </td>
</tr>
</table>
<tr>
<th> Name </th>
<th> Mail </th>
<th> Address </th>
</tr>
<tr>
<td> Jack </td>
<td> jack@gmail.com </td>
<td> London </td>
</tr>
</table>
Run Example
Bootstrap table-hover Class
you can use table-hover class for creating a hover effect on the table.
Example:
<table class="table table-hover">
<tr>
<th> Name </th>
<th> Mail </th>
<th> Address </th>
</tr>
<tr>
<td> Jack </td>
<td> jack@gmail.com </td>
<td> London </td>
</tr>
</table>
<tr>
<th> Name </th>
<th> Mail </th>
<th> Address </th>
</tr>
<tr>
<td> Jack </td>
<td> jack@gmail.com </td>
<td> London </td>
</tr>
</table>
Run Example
Bootstrap table-condensed Class
you can use table-condensed class for creating a compact table by cutting cell padding in half.
Example:
<table class="table table-condensed">
<tr>
<th> Name </th>
<th> Mail </th>
<th> Address </th>
</tr>
<tr>
<td> Jack </td>
<td> jack@gmail.com </td>
<td> London </td>
</tr>
</table>
<tr>
<th> Name </th>
<th> Mail </th>
<th> Address </th>
</tr>
<tr>
<td> Jack </td>
<td> jack@gmail.com </td>
<td> London </td>
</tr>
</table>
Run Example
Bootstrap Contextual Classes
you can color the rows or cells in different style by using these contextual classes. Bootstrap contextual classes given below:
- .active
- .success
- .warning
- .info
- .danger
Example:
<table class="table">
<tr class="success">
<th> Name </th>
<th> Mail </th>
<th> Address </th>
</tr>
<tr class="info">
<td> Jack </td>
<td> jack@gmail.com </td>
<td> London </td>
</tr>
</table>
<tr class="success">
<th> Name </th>
<th> Mail </th>
<th> Address </th>
</tr>
<tr class="info">
<td> Jack </td>
<td> jack@gmail.com </td>
<td> London </td>
</tr>
</table>
Run Example
Bootstrap Responsive Table
you can also create responsive tables using .table-responsive class. By using this class the table will scroll horizontally on the small device less than 768px.
Example:
<div class="table-responsive">
<table class="table">
<tr>
<th> Name </th>
<th> Mail </th>
<th> Address </th>
</tr>
<tr>
<td> Jack </td>
<td> jack@gmail.com </td>
<td> London </td>
</tr>
</table>
</div>
<table class="table">
<tr>
<th> Name </th>
<th> Mail </th>
<th> Address </th>
</tr>
<tr>
<td> Jack </td>
<td> jack@gmail.com </td>
<td> London </td>
</tr>
</table>
</div>
Run Example