Responsive Tables — Stack on Mobile
No JS. Keep semantic <table>
for desktop; on ≤720px each row turns into a “card” with cells labeled via data-label
.
Orders (striped)
Users (compact)
How it works: On small screens we hide thead
and display each tr
as a block “card”. Each td
reveals its header via td::before { content: attr(data-label) }
. Desktop keeps native table layout.
A11y tip: Keep concise data-label
text matching header cells. For long labels, widen the label column via grid-template-columns
.