Responsive Table Patterns
What you'll learn: How to make tables usable on small screens when they naturally want to be wide.
The Problem Tables Face on Small Screens
Tables are inherently horizontal — they spread data across columns. On a desktop monitor, a table with 6+ columns looks great. But squeeze that same table onto a phone screen, and suddenly users can't see all the data without awkwardly scrolling sideways or squinting at microscopic text.
Think of trying to read a wide newspaper on a narrow airplane tray table — either you fold it awkwardly or let parts hang off the edge.
Two Main Approaches
1. Horizontal Scrolling (Containment)
Wrap your table in a container with overflow-x: auto. The table maintains its structure but scrolls horizontally within its box:
.table-wrapper {
overflow-x: auto;
-webkit-overflow-scrolling: touch; /* smooth scrolling on iOS */
}
<div class="table-wrapper">
<table>
<!-- your table content -->
</table>
</div>
2. Layout Transformation (Stacking)
On narrow viewports, transform the table so each row becomes a card-like block. You hide the <thead> and use CSS to label each data cell:
@media (max-width: 600px) {
table, thead, tbody, tr, th, td {
display: block;
}
thead {
display: none;
}
td::before {
content: attr(data-label);
font-weight: bold;
}
}
This turns horizontal rows into vertical stacks that fit narrow screens naturally.
Key Takeaway: Responsive tables either scroll horizontally in a container or transform their layout into stacked blocks on small screens — choose based on your data complexity and user needs.