Tables are indispensable for presenting structured tabular data, such as student grade cards, financial reports, database records, and system analytics. Bootstrap 5 provides a suite of modular table classes that transform plain HTML tables into elegant, accessible, and mobile-friendly presentations with zero custom CSS.
.table ClassTo apply Bootstrap styling, add the .table class to your <table> element. This resets cell borders, adds vertical cell padding, establishes light divider borders, and aligns text to the left:
<table class="table">
<thead>
<tr>
<th scope="col"># Roll No</th>
<th scope="col">Student Name</th>
<th scope="col">Course</th>
<th scope="col">Status</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">101</th>
<td>Rahul Sharma</td>
<td>BCA 4th Sem</td>
<td><span class="badge bg-success">Passed</span></td>
</tr>
<tr>
<th scope="row">102</th>
<td>Priya Patel</td>
<td>BCA 4th Sem</td>
<td><span class="badge bg-success">Passed</span></td>
</tr>
</tbody>
</table>
Bootstrap 5 modifier classes can be chained together on the <table> element:
.table-striped: Adds alternating zebra-striping to table rows in the <tbody> for effortless reading.
.table-hover: Enables a subtle gray highlight when a user hovers their mouse pointer over rows.
.table-bordered: Adds clean borders on all sides of the table and individual cells.
.table-borderless: Removes all borders for an ultra-clean, minimalist design.
.table-sm: Compacts vertical padding in half, maximizing screen space for data-dense dashboards.
.table-responsive)On mobile smartphone screens (360px - 414px width), wide multi-column tables will break screen bounds and distort website layouts. To fix this, wrap your table inside a <div class="table-responsive">. This introduces a smooth horizontal scrollbar on small screens while keeping desktop displays standard:
<!-- Responsive Table Wrapper -->
<div class="table-responsive">
<table class="table table-striped table-hover table-bordered">
<thead class="table-dark">
<tr>
<th>Order ID</th>
<th>Customer</th>
<th>Date</th>
<th>Items</th>
<th>Total Amount</th>
<th>Payment Method</th>
<th>Shipping Status</th>
</tr>
</thead>
<tbody>
<tr class="table-success">
<td>#9401</td>
<td>Amit Verma</td>
<td>2026-11-07</td>
<td>3 Items</td>
<td>₹2,450</td>
<td>UPI Online</td>
<td>Delivered</td>
</tr>
</tbody>
</table>
</div>
Always apply scope="col" on header cells (<th>) and scope="row" on row identifier cells. This is required for W3C accessibility compliance and screen reader accessibility!
Strengthen your responsive web design mastery by studying these connected classes:
Apply table-primary, table-success, and table-hover contextual row colors.
Embed responsive tables seamlessly inside card body containers.
Add pagination controls beneath large data tables for easy navigation.
Use scope='col', caption, and proper table semantics for screen readers.
.table-responsive-sm, .table-responsive-md, or .table-responsive-lg. The table will scroll horizontally only below that breakpoint.
<tr> or <td> element, such as .table-primary, .table-success, .table-warning, or .table-danger.
.table class. Without .table, modifier classes will have no visual effect.
Advance your practical frontend engineering skills with the next topic in our synchronized curriculum.
Continue to Class 11: Images & Figures → Previous: ← Class 9: Colors & Backgrounds | Full Syllabus