HTML tables look incredibly plain and unappealing by default. Bootstrap 5 fixes this completely by providing a series of .table modifier classes that instantly add spacing, borders, and hover effects to your data.
<div class="table-responsive"> element to ensure that the table scrolls horizontally on mobile devices instead of breaking the entire page layout!
To start styling any table, all you need is the base .table class. This immediately adds light padding and horizontal divider lines.
| # | First Name | Last Name | Username |
|---|---|---|---|
| 1 | Mark | Otto | @mdo |
| 2 | Jacob | Thornton | @fat |
<div class="table-responsive">
<table class="table">
<!-- Table Content -->
</table>
</div>
Add the .table-striped class to give your table a "zebra-stripe" effect. This automatically darkens every alternating row, making dense data significantly easier to read across the screen.
| ID | Product | Price | Stock |
|---|---|---|---|
| 401 | Basic T-Shirt | $15.00 | In Stock |
| 402 | Denim Jeans | $45.00 | Low Stock |
| 403 | Hoodie | $35.00 | Out of Stock |
<!-- Basic + Striped classes -->
<table class="table table-striped">...</table>
By default, Boostrap tables only have horizontal lines. You can modify this using two classes:
.table-bordered: Adds borders on all sides of the table and internal cells..table-borderless: Removes all borders completely for a super clean, minimalist look.| Browser | Support |
|---|---|
| Chrome | Excellent |
| Firefox | Excellent |
| Browser | Support |
|---|---|
| Chrome | Excellent |
| Firefox | Excellent |
<!-- Fully Outline the grid -->
<table class="table table-bordered">...</table>
<!-- Remove all lines -->
<table class="table table-borderless">...</table>
Add the .table-hover class to enable a hover effect on table rows. When a user moves their mouse vertically across the table, the row underneath their cursor will slightly darken. This makes tracking horizontal data on wide screens incredibly easy.
| Invoice # | Date | Status |
|---|---|---|
| INV-1001 | Oct 24, 2023 | Paid |
| INV-1002 | Oct 26, 2023 | Pending |
| INV-1003 | Nov 01, 2023 | Overdue |
<table class="table table-hover">...</table>
If you have an enormous amount of data and want to fit more rows onto the screen, add the .table-sm class. This cuts cell padding in half, creating a visibly denser, tighter table.
| # | Metric | Value |
|---|---|---|
| 1 | Users | 14,500 |
| 2 | Bounce Rate | 45% |
<table class="table table-sm table-bordered">...</table>