← Learning Hub
Intermediate

Tables and List Groups

Add .table to any <table> for clean spacing and lines. Extra classes change the look.

Tables of data appear in dashboards, price comparisons and order histories. Raw HTML tables look cramped; Bootstrap's table classes add spacing, borders, stripes and hover highlights with one class each, and table-responsive lets wide tables scroll sideways on phones instead of breaking the page.

  • table-striped - zebra rows; table-hover - row highlight on hover
  • table-bordered, table-sm (compact), table-dark
  • table-success, table-danger... on a row - colour one row
  • Wrap in .table-responsive so wide tables scroll sideways on phones
Example
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
  </head>
  <body class="p-3">
    <div class="table-responsive">
      <table class="table table-striped table-hover align-middle">
        <thead class="table-dark">
          <tr><th>#</th><th>Order</th><th>Amount</th><th>Status</th></tr>
        </thead>
        <tbody>
          <tr><td>1</td><td>Mobile cover</td><td>₹299</td><td><span class="badge text-bg-success">Delivered</span></td></tr>
          <tr><td>2</td><td>Earbuds</td><td>₹1,499</td><td><span class="badge text-bg-warning">Shipped</span></td></tr>
          <tr class="table-danger"><td>3</td><td>Smart watch</td><td>₹3,999</td><td><span class="badge text-bg-danger">Cancelled</span></td></tr>
        </tbody>
      </table>
    </div>
  </body>
</html>
▶ Try it yourself

List groups

A list group shows a neat column of items - settings menus, notifications, a cart summary.

Example
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
  </head>
  <body class="p-3">
    <div class="list-group" style="max-width: 360px">
      <a href="#" class="list-group-item list-group-item-action active">My orders</a>
      <a href="#" class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
        Wishlist <span class="badge text-bg-primary rounded-pill">4</span>
      </a>
      <a href="#" class="list-group-item list-group-item-action">Addresses</a>
      <a href="#" class="list-group-item list-group-item-action disabled">Gift cards (soon)</a>
    </div>
  </body>
</html>
▶ Try it yourself
Use tables only for real table data (rows and columns of information), not for page layout. Use the grid for layout.
Key points
  • Add .table, then extras like table-striped and table-hover.
  • Wrap wide tables in .table-responsive.
  • List groups make neat vertical lists of items.

📝 Test yourself

1. Which class gives tables zebra stripes?
2. How do you stop a wide table from breaking a phone layout?
3. Fill in the class for one item in a list group:
<li class="list-group-">Item</li>