Advertisement
Google Ad Slot: content-top
Bootstrap 5 Table
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.
Basic Table:
To create a basic table, use the .table class:
Striped Rows:
Add the table-striped class to create striped rows for better readability.
Bordered Table:
Add the table-bordered class to create borders to all table cells.
Hoverable Rows:
Add the table-hover to highlight rows when hovered.
Responsive Table:
To make tables scrollable on smaller screens, wrap them in .table-responsive.
Small Table:
Use .table-sm to make a more compact table with smaller cell padding.
Table with Dark Theme:
Use .table-dark for a dark background with light text.
Contextual Classes:
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 |
Aligning Content:
Use alignment classes inside table cells.
Class Name |
Alignment |
|---|---|
.text-start |
Left align |
.text-center |
Center align |
.text-end |
Right align |
Combining Styles:
Combine multiple classes for a styled table: