Add horizontal scrollbar to html table

Tsundoku picture Tsundoku · Apr 4, 2011 · Viewed 316.9k times · Source

Is there a way to add a Horizontal scrollbar to an HTML table? I actually need it to be scrollable both vertically and horizontally depending on how the table grows but I can't get either scrollbar to appear.

Answer

Serge Stroobandt picture Serge Stroobandt · May 24, 2015

First, make a display: block of your table

then, set overflow-x: to auto.

table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
}

Nice and clean. No superfluous formatting.

Here are more involved examples with scrolling table captions from a page on my website.