×

Html & Html5

The World's best Software Development Study Portal

Tables in Bootstrap


In Bootstrap we can easily design our table just by implementing the class of table.


Let’s understand these class:-


The .table class adds only basic style in table .
Let’s understand this by following program


<!DOCTYPE html>

<html lang="en">

<head>

<title> bootstrap 5 Example</title>

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>



</head>

<body>

<div class="container">

<h2>Basic Table</h2>

<table class="table">

<thead>

<tr>

<th>Firstname</th>

<th>Lastname</th>

<th>Rollno</th>

</tr>

</thead>

<tbody>

<tr>

<td>suman</td>

<td>Rani</td>

<td>22</td>

</tr>

<tr>

<td>kiran</td>

<td>Rani</td>

<td>28</td>

</tr>

<tr>

<td>Neelam</td>

<td>Rani</td>

<td>29</td>

</tr>

</tbody>

</table>

</div>

</body>

</html>

</div>

Output of this Program


bootstrap 5 Example

Basic Table

Firstname Lastname Rollno
suman Rani 22
kiran Rani 28
Neelam Rani 29



So here so easily we have created our basic table .



The .table-bordered class adds border in the table .
Let’s understand this by following program


<!DOCTYPE html>

<html lang="en">

<head>

<title> bootstrap 5 Example</title>

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>



</head>

<body>

<div class="container">

<h2>table-bordered</h2>

<table class="table table-bordered">

<thead>

<tr>

<th>Firstname</th>

<th>Lastname</th>

<th>Rollno</th>

</tr>

</thead>

<tbody>

<tr>

<td>suman</td>

<td>Rani</td>

<td>22</td>

</tr>

<tr>

<td>kiran</td>

<td>Rani</td>

<td>28</td>

</tr>

<tr>

<td>Neelam</td>

<td>Rani</td>

<td>29</td>

</tr>

</tbody>

</table>

</div>

</body>

</html>

Output of this Program


bootstrap 5 Example

table-bordered

Firstname Lastname Rollno
suman Rani 22
kiran Rani 28
Neelam Rani 29

Here by .table-bordered we get border in our table




The .table-striped class adds border in the table .
Let’s understand this by following program


<!DOCTYPE html>

<html lang="en">

<head>

<title> bootstrap 5 Example</title>

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>



</head>

<body>

<div class="container">

<h2>Striped Rows</h2>

<table class="table table-striped">

<thead>

<tr>

<th>Firstname</th>

<th>Lastname</th>

<th>Rollno</th>

</tr>

</thead>

<tbody>

<tr>

<td>suman</td>

<td>Rani</td>

<td>22</td>

</tr>

<tr>

<td>kiran</td>

<td>Rani</td>

<td>28</td>

</tr>

<tr>

<td>Neelam</td>

<td>Rani</td>

<td>29</td>

</tr>

</tbody>

</table>

</div>

</body>

</html>

Output of this Program


bootstrap 5 Example

Striped Rows

Firstname Lastname Rollno
suman Rani 22
kiran Rani 28
Neelam Rani 29

The .table-dark class adds border in the table .
Let’s understand this by following program


<!DOCTYPE html>

<html lang="en">

<head>

<title> bootstrap 5 Example</title>

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>



</head>

<body>

<div class="container">

<h2>Black/Dark Table</h2>

<table class="table table-dark">

<thead>

<tr>

<th>Firstname</th>

<th>Lastname</th>

<th>Rollno</th>

</tr>

</thead>

<tbody>

<tr>

<td>suman</td>

<td>Rani</td>

<td>22</td>

</tr>

<tr>

<td>kiran</td>

<td>Rani</td>

<td>28</td>

</tr>

<tr>

<td>Neelam</td>

<td>Rani</td>

<td>29</td>

</tr>

</tbody>

</table>

</div>

</body>

</html>

Output of this Program


bootstrap 5 Example

Black/Dark Table

Firstname Lastname Rollno
suman Rani 22
kiran Rani 28
Neelam Rani 29

The .table-hover class adds hover effect in the table .
Let’s understand this by following program


<!DOCTYPE html>

<html lang="en">

<head>

<title> bootstrap 5 Example</title>

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>



</head>

<body>

<div class="container">

<h2>table-hover</h2>

<table class="table table-hover">

<thead>

<tr>

<th>Firstname</th>

<th>Lastname</th>

<th>Rollno</th>

</tr>

</thead>

<tbody>

<tr>

<td>suman</td>

<td>Rani</td>

<td>22</td>

</tr>

<tr>

<td>kiran</td>

<td>Rani</td>

<td>28</td>

</tr>

<tr>

<td>Neelam</td>

<td>Rani</td>

<td>29</td>

</tr>

</tbody>

</table>

</div>

</body>

</html>

Output of this Program


bootstrap 5 Example

table-hover

Firstname Lastname Rollno
suman Rani 22
kiran Rani 28
Neelam Rani 29

Name Description
.table-striped Adds Zebra stripes on table rows
.table-hover Adds hover effect on table rows
.table-dark Adds black background to table
.table-primary Blue color indicating an important action
.table-success Green color indicating a successful or positive action
.table-danger Red: Indicates a dangerous or potentially negative action
.table-info Light blue: Indicates a neutral informative change or action
.table-warning Orange: Indicates a warning that might need attention
.table-active Grey: Applies the hover color to the table row or table cell
.table-secondary Grey: Indicates a slightly less important action
.table-light Light grey table or table row background
.table-dark Dark grey table or table row background







Bootstrap 4 training insitute | Best IT Training classes in Gurgaon | Web Designing Training Institute