Bootstrap 5 Basic
Bootstrap 5 Utilities
Bootstrap 5 Flexbox
In Bootstrap 5, creating and styling tables is simple and flexible with a variety of built-in table classes. These classes help you quickly design tables with different styles, colors, borders, and responsive behavior.
To create a basic table, use the .table class:
Add the table-striped class to create striped rows for better readability.
Add the table-bordered class to create borders to all table cells.
Add the table-hover to highlight rows when hovered.
To make tables scrollable on smaller screens, wrap them in .table-responsive.
Use .table-sm to make a more compact table with smaller cell padding.
Use .table-dark for a dark background with light text.
Add row or cell-level styling with contextual classes:
|
Class |
Description |
|---|---|
|
.table-primary |
Blue background |
|
.table-secondary |
Gray background |
|
.table-success |
Green background |
|
.table-danger |
Red background |
|
.table-warning |
Yellow background |
|
.table-info |
Light blue background |
|
.table-light |
Light background |
|
.table-dark |
Dark background |
Use alignment classes inside table cells.
|
Class Name |
Alignment |
|---|---|
|
.text-start |
Left align |
|
.text-center |
Center align |
|
.text-end |
Right align |
Combine multiple classes for a styled table: