Bootstrap4 Tables
Bootstrap4 Basic Tables
Bootstrap4 sets the style of basic tables through the .table class, as shown in the example below:
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
tableTry it »
Striped table
By adding the .table-striped class, you will , as shown in the example below:
Example
<table class=">table table-striped
"
<
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
tableTry it »
Bordered Table
The .table-bordered class can add borders to the table
Example
<table class=">table table-bordered
"
<
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
tableTry it »
Hover State Table
The .table-hover class can add a mouse hover effect (gray background) to each row of the table:
Example
<table class=">table table-hover
"
<
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
tableTry it »
Black Background Table
The .table-dark class can add a black background to the table:
Example
<table class=">table table-dark
"
<
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
tableTry it »
Black Striped Table
Using the .table-dark and .table-striped classes together can create a black striped table:
Example
<table class=">table table-dark table-striped
"
<
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
tableTry it »
Hover Effect - Black Background Table
Using the .table-dark and .table-hover classes together can set the hover effect of a black background table:
Example
<table class=">table table-dark table-hover
"
<
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
tableTry it »
Borderless Table
The .table-borderless class can set a borderless table:
Example
<table class=">table table-borderless
"
<
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
tableTry it »
Meaningful Color Classes
Meaningful color classes can set colors for table rows or cells:
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
=
"table-dark text-dark
"
<
td
Dark
td
<
td
Bo
td
<
td
bo@example.com
td
tr
tbody
tableTry it »
The table below lists the descriptions of table color classes:
| 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
In Bootstrap v4.0.0-beta.2, the .thead-dark class is used to add a black background to the table header, and the .thead-light class is used to add a gray background to the table header:
In the Bootstrap v4.0.0-beta version,.thead-inverse class is used to add a black background to the table header,.thead-default class is used to add a gray background to the table header.
Example
<
table
class
=
"
table
"
<
thead
class
=
"
thead-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
=
"
thead-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
tableTry it »
Smaller Table
The .table-sm class is used to set a smaller table by reducing padding:
Example
<table class=">table table-bordered table-sm
"
<
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
tableTry it »
Responsive table
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):
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
<
tdNew York
td
<
td
USA
td
<
td
Female
td
<
td
Yes
td
<
td
Yes
td
<
td
Yes
td
<
td
Yes
td
tr
tbody
table
divTry it »
You can use the following classes to set the display of scrollbars at specified screen widths:
| Class Names | Screen Width |
|---|---|
| .table-responsive-sm | < 576px |
| .table-responsive-md | < 768px |
| .table-responsive-lg | < 992px |
| .table-responsive-xl | < 1200px |
Example
<div class="table-responsive-sm">
<table class="table">...
table
div
Try it »