Basic Table
A basic Bootstrap 5 table has a light padding and horizontal dividers.
The .table
class adds basic styling to a table:
Bootstrap Tables
Fristname | Lastname | |
---|---|---|
Ram | Kumar | ram@example.com |
Mohan | kumar | mohan@example.com |
Sohan | kumar | sohan@example.com |
Striped Rows
The .table-striped class adds zebra-stripes to a table:
Fristname | Lastname | |
---|---|---|
Ram | Kumar | ram@example.com |
Mohan | kumar | mohan@example.com |
Sohan | kumar | sohan@example.com |
Bordered Table
The .table-bordered class adds borders on all sides of the table and cells:
Fristname | Lastname | |
---|---|---|
Ram | Kumar | ram@example.com |
Mohan | kumar | mohan@example.com |
Sohan | kumar | sohan@example.com |
Hover Rows
The .table-hover
class adds a hover effect (grey background color) on table rows:
Fristname | Lastname | |
---|---|---|
Ram | Kumar | ram@example.com |
Mohan | kumar | mohan@example.com |
Sohan | kumar | sohan@example.com |
Black/Dark Table
The .table-dark
class adds a black background to the table:
Fristname | Lastname | |
---|---|---|
Ram | Kumar | ram@example.com |
Mohan | kumar | mohan@example.com |
Sohan | kumar | sohan@example.com |
Dark Striped Table
Combine .table-dark and .table-striped to create a dark, striped table:
Fristname | Lastname | |
---|---|---|
Ram | Kumar | ram@example.com |
Mohan | kumar | mohan@example.com |
Sohan | kumar | sohan@example.com |
Hoverable Dark Table
The .table-hover
class adds a hover effect (grey background color) on table rows:
Fristname | Lastname | |
---|---|---|
Ram | Kumar | ram@example.com |
Mohan | kumar | mohan@example.com |
Sohan | kumar | sohan@example.com |
Borderless Table
The .table-borderless
class removes borders from the table:
Fristname | Lastname | |
---|---|---|
Ram | Kumar | ram@example.com |
Mohan | kumar | mohan@example.com |
Sohan | kumar | sohan@example.com |
Contextual Classes
Contextual classes can be used to color the whole table (<table>), the table rows (<tr>) or table cells (<td>).
Firstname | Lastname | |
---|---|---|
Default | Defaultson | def@somemail.com |
Primary | Joe | joe@example.com |
Success | Doe | john@example.com |
Danger | Moe | mary@example.com |
Info | Dooley | july@example.com |
Warning | Refs | bo@example.com |
Active | Activeson | act@example.com |
Secondary | Secondson | sec@example.com |
Light | Angie | angie@example.com |
Dark | Bo | bo@example.com |
Table Head Colors
You can also use any of the contextual classes to only add a background color to the table header:
Firstname | Lastname | |
---|---|---|
John | Doe | john@example.com |
Mary | Moe | mary@example.com |
July | Dooley | july@example.com |
Firstname | Lastname | |
---|---|---|
Ram | kumar | ram@example.com |
Sohan | Moe | sona@example.com |
ravi | Dooley | ravi@example.com |
Small table
The .table-sm
class makes the table smaller by cutting cell padding in half:
Firstname | Lastname | |
---|---|---|
Ram | Kumar | ram@example.com |
Mohan | Kumar | mohan@example.com |
Sohan | Kumar | sohan@example.com |
Responsive Tables
The .table-responsive
class adds a scrollbar to the table when needed (when it is too big horizontally):
Example
<div class="table-responsive"> <table class="table"> ... </table> </div>You can click on above box to edit the code and run again.
Output
# | Firstname | Lastname | Age | City | Country | Sex | Example | Example | Example | Example | Example | Example |
---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | ram | kumar | 35 | New York | india | male | Yes | Yes | Yes | Yes | Yes | Yes |