Bootstrap5 Tables
Bootstrap 5's Table component provides a series of features and styles, making tables easier to build, responsive, and visually appealing.
We can easily create tables with different styles, sorting, pagination, and responsive layouts.
Bootstrap5 Basic Table
In Bootstrap 5, the basic structure for creating a table is simple - just use standard HTML Bootstrap5 uses the .table class to style basic tables, as shown in the following example: Try it » By adding the .table-striped class, you will , as shown in the example below: table table-striped " Try it » The .table-bordered class can add borders to the table table table-bordered " Try it » The .table-hover class can add a mouse hover effect (gray background) to each row of the table: table table-hover " Try it » The .table-dark class can add a black background to the table: table table-dark " Try it » Using the .table-dark and .table-striped classes together can create a black striped table: table table-dark table-striped " Try it » Using the .table-dark and .table-hover classes together can set the hover effect of a black background table: table table-dark table-hover " Try it » The .table-borderless class can set a borderless table: table table-borderless " Try it » Meaningful color classes can set colors for table rows or cells: table-dark text-dark " Try it » The table below lists the descriptions of table color classes: We can also set the color of the table header. For example, the .table-dark class adds a black background to the header, and the .table-light class adds a gray background to the header: Try it » The .table-sm class is used to set a smaller table by reducing padding: table table-bordered table-sm " Try it » The .table-responsive class is used to create a responsive table: a horizontal scrollbar is created when the screen width is less than 992px; if the visible area width is greater than 992px, a different effect is shown (no scrollbar): New York
td Try it » You can use the following classes to set the display of scrollbars at specified screen widths: ...
table
div Try it » elements, and add
table class.
Example
<
table
class
=
"
table
"
<
thead
<
tr
<
th
Firstname
th
<
th
Lastname
th
<
th
Email
th
tr
thead
<
tbody
<
tr
<
td
John
td
<
td
Doe
td
<
td
john@example.com
td
tr
<
tr
<
td
Mary
td
<
td
Moe
td
<
td
mary@example.com
td
tr
<
tr
<
td
July
td
<
td
Dooley
td
<
td
july@example.com
td
tr
tbody
table
Striped table
Example
<table class="><
thead
<
tr
<
th
Firstname
th
<
th
Lastname
th
<
th
Email
th
tr
thead
<
tbody
<
tr
<
td
John
td
<
td
Doe
td
<
td
john@example.com
td
tr
<
tr
<
td
Mary
td
<
td
Moe
td
<
td
mary@example.com
td
tr
<
tr
<
td
July
td
<
td
Dooley
td
<
td
july@example.com
td
tr
tbody
table
Bordered Table
Example
<table class="><
thead
<
tr
<
th
Firstname
th
<
th
Lastname
th
<
th
Email
th
tr
thead
<
tbody
<
tr
<
td
John
td
<
td
Doe
td
<
td
john@example.com
td
tr
<
tr
<
td
Mary
td
<
td
Moe
td
<
td
mary@example.com
td
tr
<
tr
<
td
July
td
<
td
Dooley
td
<
td
july@example.com
td
tr
tbody
table
Hover State Table
Example
<table class="><
thead
<
tr
<
th
Firstname
th
<
th
Lastname
th
<
th
Email
th
tr
thead
<
tbody
<
tr
<
td
John
td
<
td
Doe
td
<
td
john@example.com
td
tr
<
tr
<
td
Mary
td
<
td
Moe
td
<
td
mary@example.com
td
tr
<
tr
<
td
July
td
<
td
Dooley
td
<
td
july@example.com
td
tr
tbody
table
Black Background Table
Example
<table class="><
thead
<
tr
<
th
Firstname
th
<
th
Lastname
th
<
th
Email
th
tr
thead
<
tbody
<
tr
<
td
John
td
<
td
Doe
td
<
td
john@example.com
td
tr
<
tr
<
td
Mary
td
<
td
Moe
td
<
td
mary@example.com
td
tr
<
tr
<
td
July
td
<
td
Dooley
td
<
td
july@example.com
td
tr
tbody
table
Black Striped Table
Example
<table class="><
thead
<
tr
<
th
Firstname
th
<
th
Lastname
th
<
th
Email
th
tr
thead
<
tbody
<
tr
<
td
John
td
<
td
Doe
td
<
td
john@example.com
td
tr
<
tr
<
td
Mary
td
<
td
Moe
td
<
td
mary@example.com
td
tr
<
tr
<
td
July
td
<
td
Dooley
td
<
td
july@example.com
td
tr
tbody
table
Hover Effect - Black Background Table
Example
<table class="><
thead
<
tr
<
th
Firstname
th
<
th
Lastname
th
<
th
Email
th
tr
thead
<
tbody
<
tr
<
td
John
td
<
td
Doe
td
<
td
john@example.com
td
tr
<
tr
<
td
Mary
td
<
td
Moe
td
<
td
mary@example.com
td
tr
<
tr
<
td
July
td
<
td
Dooley
td
<
td
july@example.com
td
tr
tbody
table
Borderless Table
Example
<table class="><
thead
<
tr
<
th
Firstname
th
<
th
Lastname
th
<
th
Email
th
tr
thead
<
tbody
<
tr
<
td
John
td
<
td
Doe
td
<
td
john@example.com
td
tr
<
tr
<
td
Mary
td
<
td
Moe
td
<
td
mary@example.com
td
tr
<
tr
<
td
July
td
<
td
Dooley
td
<
td
july@example.com
td
tr
tbody
table
Meaningful Color Classes
Example
<
table
class
=
"
table
"
<
thead
<
tr
<
th
Firstname
th
<
th
Lastname
th
<
th
Email
th
tr
thead
<
tbody
<
tr
<
td
Default
td
<
td
Defaultson
td
<
td
def@somemail.com
td
tr
<
tr
class
=
"
table-primary
"
<
td
Primary
td
<
td
Joe
td
<
td
joe@example.com
td
tr
<
tr
class
=
"
table-success
"
<
td
Success
td
<
td
Doe
td
<
td
john@example.com
td
tr
<
tr
class
=
"
table-danger
"
<
td
Danger
td
<
td
Moe
td
<
td
mary@example.com
td
tr
<
tr
class
=
"
table-info
"
<
td
Info
td
<
td
Dooley
td
<
td
july@example.com
td
tr
<
tr
class
=
"
table-warning
"
<
td
Warning
td
<
td
Refs
td
<
td
bo@example.com
td
tr
<
tr
class
=
"
table-active
"
<
td
Active
td
<
td
Activeson
td
<
td
act@example.com
td
tr
<
tr
class
=
"
table-secondary
"
<
td
Secondary
td
<
td
Secondson
td
<
td
sec@example.com
td
tr
<
tr
class
=
"
table-light
"
<
td
Light
td
<
td
Angie
td
<
td
angie@example.com
td
tr
<
tr
class
=
"<
td
Dark
td
<
td
Bo
td
<
td
bo@example.com
td
tr
tbody
table
Class Names
Description
.table-primary
Blue: Indicates this is an important action
.table-success
Green: Indicates this is a permitted action
.table-danger
Red: Indicates this is a dangerous action
.table-info
Light blue: Indicates the content has changed
.table-warning
Orange: Indicates an action that needs attention
.table-active
Gray: Used for hover effects
.table-secondary
Gray: Indicates the content is not very important
.table-light
Light gray, can be the background of a table row
.table-dark
Dark gray, can be the background of a table row
Table Header Colors
Example
<
table
class
=
"
table
"
<
thead
class
=
"
table-dark
"
<
tr
<
th
Firstname
th
<
th
Lastname
th
<
th
Email
th
tr
thead
<
tbody
<
tr
<
td
John
td
<
td
Doe
td
<
td
john@example.com
td
tr
<
tr
<
td
Mary
td
<
td
Moe
td
<
td
mary@example.com
td
tr
<
tr
<
td
July
td
<
td
Dooley
td
<
td
july@example.com
td
tr
tbody
table
<
table
class
=
"
table
"
<
thead
class
=
"
table-light
"
<
tr
<
th
Firstname
th
<
th
Lastname
th
<
th
Email
th
tr
thead
<
tbody
<
tr
<
td
John
td
<
td
Doe
td
<
td
john@example.com
td
tr
<
tr
<
td
Mary
td
<
td
Moe
td
<
td
mary@example.com
td
tr
<
tr
<
td
July
td
<
td
Dooley
td
<
td
july@example.com
td
tr
tbody
table
Smaller Table
Example
<table class="><
thead
<
tr
<
th
Firstname
th
<
th
Lastname
th
<
th
Email
th
tr
thead
<
tbody
<
tr
<
td
John
td
<
td
Doe
td
<
td
john@example.com
td
tr
<
tr
<
td
Mary
td
<
td
Moe
td
<
td
mary@example.com
td
tr
<
tr
<
td
July
td
<
td
Dooley
td
<
td
july@example.com
td
tr
tbody
table
Responsive table
Example
<
div
class
=
"
table-responsive
"
<
table
class
=
"
table
"
<
thead
<
tr
<
th
th
<
th
Firstname
th
<
th
Lastname
th
<
th
Age
th
<
th
City
th
<
th
Country
th
<
th
Sex
th
<
th
Example
th
<
th
Example
th
<
th
Example
th
<
th
Example
th
tr
thead
<
tbody
<
tr
<
td
1
td
<
td
Anna
td
<
td
Pitt
td
<
td
35
td
<
td<
td
USA
td
<
td
Female
td
<
td
Yes
td
<
td
Yes
td
<
td
Yes
td
<
td
Yes
td
tr
tbody
table
div
Class Names
Screen Width
.table-responsive-sm
< 576px
.table-responsive-md
< 768px
.table-responsive-lg
< 992px
.table-responsive-xl
< 1200px
.table-responsive-xxl
< 1400px
Example
<div class="table-responsive-sm">
<table class="table">