Bootstrap 5 Tables

Bootstrap 5 includes table classes that assist with building consistently styled and responsive tables.

Bootstrap doesn't provide any default styling for tables. In other words, Bootstrap's table styles are opt-in. To use Bootstrap's styles for tables, use Bootstrap's .table class, then apply any additional modifier classes or custom styles as required.

Also, Bootstrap's table styles are not inherited, meaning any nested tables can be styled independent from the parent.

Basic Table

For a basic table with lightly padded cells and horizontal dividers, apply Bootstrap's .table class to the <table> element.

View Output

Dark Table

You can use the .table-dark class to invert the colors so that it has light text on a dark background.

View Output

Striped Table

For alternating background colors on the rows, add Bootstrap's .table-striped class (while keeping the .table class in place).

View Output

Bordered Table

For borders all around the table, use Bootstrap's .table-bordered class (while keeping the .table class in place).

View Output

Hover Rows

To achieve that "hover" effect when mousing over the table rows, use Bootstrap's .table-hover class (while keeping the .table class in place).

View Output

Small/Condensed Table

If you find a table has too much padding, you can half the padding by using Bootstrap's .table-sm class (while keeping the .table class in place).

View Output

Contextual Classes

You can apply color to individual rows or cells by using Bootstrap's contextual classes.

The 5 contextual classes are: .table-active, .table-success, .table-info, .table-warning, and .table-danger.

View Output

This can also be applied at the table level:

View Output

Responsive Tables

Responsive tables automatically create horizontal scrollbars when viewed on devices smaller than a given breakpoint.

To create a responsive table, enclose the table in a <div> element that has the .table-responsive class (or one of the .table-responsive-* classes) applied.

View Output

The .table-responsive-* classes can be used to specify a specific breakpoint. They are .table-responsive-sm, .table-responsive-md, .table-responsive-lg, .table-responsive-xl and .table-responsive-xxl.

From that breakpoint and up, the table will behave normally and not scroll horizontally.