# Tables and Data Specialist reference: Responsive Tables
Part of the `tables-data-specialist` skill. Read this only when the task reaches these sections.
## Responsive Tables
### Approach 1: Horizontal Scroll
```html
```
- Wrap in a `
` with `role="region"` and `aria-label`
- Add `tabindex="0"` so keyboard users can scroll
- Add `overflow-x: auto` on the wrapper
- Visual scroll indicator so users know there's more content
### Approach 2: Stacked Cards on Mobile
```css
@media (max-width: 768px) {
table, thead, tbody, th, td, tr {
display: block;
}
thead { display: none; } /* Hide visual headers */
td::before {
content: attr(data-label); /* Show header as label */
font-weight: bold;
}
}
```
```html
Jane Smith
jane@example.com
```
Requirements for stacked pattern:
- Each cell must have its header visible (via `data-label` or other technique)
- `thead { display: none; }` hides the headers from screen readers too. Hide them visually with a visually-hidden class instead if screen readers should keep them
- Changing `display` on table elements can drop their table semantics in some browsers; restore them with explicit roles (`role="table"`, `rowgroup`, `row`, `columnheader`, `cell`) and test with a screen reader
- Row boundaries must be clear (borders, spacing, or visual grouping)
### Approach 3: Priority Columns
Show only essential columns on mobile, with a "View details" button per row:
```html
Jane Smith
jane@example.com
Admin
```
Hide columns with `display: none`, which also removes them for assistive technology. Never use `aria-hidden` alone: the content stays visible and focusable.