← Back to Bootstrap Course | Chapter 10: Responsive Design | Lesson 3 of 7

Responsive tables

Wide tables become horizontally scrollable on small screens instead of breaking the layout.

In this page:

  1. Responsive tables
Syntax
markup
<div class="table-responsive">
  <table class="table">...</table>
</div>

Responsive tables

Wrap a .table in .table-responsive (or .table-responsive-md to scroll only below md). Bootstrap tables also offer .table-striped, .table-hover, .table-bordered, .table-sm and colour variants. Keep the number of columns reasonable for mobile.

Note: table-responsive adds a horizontal scrollbar only when needed.

Example: Responsive tables

markup
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<div class="container">
  <div class="table-responsive">
    <table class="table table-striped table-hover">
      <thead><tr><th>#</th><th>Name</th><th>Role</th><th>City</th><th>Email</th><th>Joined</th></tr></thead>
      <tbody>
        <tr><td>1</td><td>Ada</td><td>Engineer</td><td>London</td><td>[email protected]</td><td>2024-01-05</td></tr>
        <tr><td>2</td><td>Linus</td><td>Maintainer</td><td>Portland</td><td>[email protected]</td><td>2024-02-11</td></tr>
      </tbody>
    </table>
  </div>
</div>
</body>
</html>
Live Example
Related Topics
Common Mistakes
  1. Forgetting the responsive wrapper
  2. Too many columns for phones
  3. Putting table-responsive on the table element
Chapter Summary
  • table-responsive on a wrapper
  • Breakpoint versions exist
  • table-striped and table-hover style rows
  • Wrapper, not the table itself
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.