Horizontally Scrollable Table Template

Make any wide table responsive with the simplest and most reliable method: horizontal scrolling.

By wrapping your table in a container with an overflow property, you can ensure your data is always accessible on mobile devices without breaking your page layout.

Screenshot showing a table on a mobile-sized screen with a horizontal scrollbar at the bottom.

Get Source Code → Preview →

About this Responsive Table Method

Tables, by their nature, are wide. When a wide table is viewed on a narrow screen, it will often "break" the page layout by overflowing its container and forcing the entire page to scroll horizontally. This is a poor user experience.

This template solves the problem elegantly. The technique involves two parts:

  1. The table itself is allowed to be as wide as it needs to be.
  2. It is placed inside a wrapper div. This wrapper is given the CSS property overflow-x: auto;.

The result is that on a wide screen, no change is visible. But on a screen narrower than the table, the table content itself becomes scrollable, while the rest of the page remains fixed. It's a robust, cross-browser solution that preserves the table's structure for all users.

Key Features:

Ideal Use Cases:

Code

Here's the full code for the horizontally scrollable table:

View Output