Headers
Column names define how data should be read.
Tables are for comparing structured data. Good table CSS makes dense information scannable without destroying semantic table markup.
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
td[data-type="number"] { text-align: right; }
Component mental model
A table is not old-fashioned. It is the correct HTML structure for rows and columns of related data.
Table styling should support scanning: clear headers, row rhythm, numeric alignment, sticky headers when useful and sensible responsive behavior.
The common mistake is either overdesigning tables until they become noisy, or replacing real tabular data with divs and losing semantics.
Column names define how data should be read.
Spacing and borders help users track across the table.
Numbers often need different alignment than text.
Wide tables need a planned small-screen behavior.
Visual model
Headers explain each column.
Data is grouped for comparison.
Numeric data scans better when aligned.
Wide data gets an overflow strategy.
Good CSS versus fragile CSS
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; }
td, th { padding: .875rem 1rem; }
td[data-type="number"] { text-align: right; font-variant-numeric: tabular-nums; }
.row { display: flex; }
.cell { width: 25%; }
.header { font-weight: bold; }
Rules of thumb
Rows and columns deserve semantic table elements.
Numeric columns often scan best right-aligned with tabular nums.
Use borders or subtle backgrounds, not heavy decoration everywhere.
Small screens need horizontal scroll, stacked cards or reduced columns intentionally.
A caption can explain what the table represents.
Use tables for data, not page layout.
Production thinking
Good tables turn raw data into decisions. Bad tables make users hunt row by row.
Semantic table markup connects headers and cells for assistive technology.
Test tables with many rows, long labels and narrow screens. Dense data breaks layout quickly.
Structured table content can help users and crawlers understand factual comparisons.
Live code lab
The preview runs in an isolated iframe. Links and forms stay inside the practice area, so you can experiment without leaving the lesson.
Mini assignment
Practice assignment
Try it yourself
Self-check
Answer these questions before moving on. If a state, long label or mobile width breaks the component, the component is not finished yet.
Senior audit upgrade
A table is not a card grid. Headers, captions, numeric alignment and overflow behavior carry meaning.
A caption can explain what the table represents before users scan data.
Useful for large tables, but test overlap and scroll containers.
If horizontal scrolling is required, make that possibility visible.