concept

Responsive table scrolling — CSS reference

For wide tabular data, place the semantic table in a scrollable wrapper rather than force narrow columns that destroy readability. Preserve the caption and header associations. A focusable, labeled wrapper is useful for keyboard scrolling; this test verifies scroll geometry, not full accessibility.

Formal Syntax & Structure

css syntaxcss
.table-wrap { overflow-x: auto; }

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>Responsive table scrolling</title><style>body{margin:0}#a{padding:8px;background:rgb(232,237,241);color:rgb(0,0,0);box-sizing:border-box}body{font:16px/20px sans-serif;background:white}#a{padding:0;background:transparent;margin:10px;color:black}table{border-spacing:0}td,th{padding:0}caption{padding:0}#a{width:240px;overflow-x:auto}table{width:420px;table-layout:fixed}td{height:30px}</style><body><div id="a" tabindex="0" role="region" aria-label="Inventory table"><table><caption>Inventory</caption><tr><th scope="col">Product</th><th scope="col">Qty</th></tr><tr><td>Pen</td><td>5</td></tr></table></div></body></html>
CSS Reference