Class 10 of 48 • Content & Typography

Bootstrap 5 Tables: Formatting, Contextual Colors & Responsive Design

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.

Bootstrap 5 Responsive Tables: Striped, Bordered, Hover, and Table-Responsive
Figure 10: Table styling variants showing striping, hover feedback, active states, and mobile horizontal scrolling wrappers.

1. The Base .table Class

To 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>

2. Table Modifier Classes

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.


3. Mobile Responsive Tables (.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>

University Lab Practical Exam Rule

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!

Explore Related Bootstrap Tutorials & Next Steps

Strengthen your responsive web design mastery by studying these connected classes:

Contextual Colors & Backgrounds

Apply table-primary, table-success, and table-hover contextual row colors.

Cards with Embedded Tables

Embed responsive tables seamlessly inside card body containers.

Pagination for Data Tables

Add pagination controls beneath large data tables for easy navigation.

Accessible Data Tables (ARIA)

Use scope='col', caption, and proper table semantics for screen readers.

Frequently Asked Questions (FAQ) - Student & Interview Review

Yes! Use breakpoint-specific classes such as .table-responsive-sm, .table-responsive-md, or .table-responsive-lg. The table will scroll horizontally only below that breakpoint.
Apply contextual classes directly to the <tr> or <td> element, such as .table-primary, .table-success, .table-warning, or .table-danger.
Bootstrap modifier classes rely on CSS specificity and inherit properties from the parent .table class. Without .table, modifier classes will have no visual effect.

Next Step in Your Bootstrap Learning Path:

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

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Reddit

You may also like this!