Containers
The constraint that stops content spreading to unusable widths, and increasingly the unit that components respond to.
Definition
A container bounds content width and provides consistent horizontal padding. With container queries, containers also become the reference for component-level responsive behaviour, replacing viewport assumptions.
Craft convention. True because the industry converged on it. Breaking it costs familiarity, not correctness.
On this plate
Reach for this when
- Setting page and content widths.
- Building reusable components.
- Reviewing layouts on very wide displays.
- A component is reused at several widths and is starting to grow variants.
Common mistakes
- Unconstrained prose width.
- Components that assume viewport width equals available width.
- Container padding that disappears at small viewports.
Container widths by content type
| Content | Max width | Reason |
|---|---|---|
| Continuous prose | 60 to 70ch, about 640 to 720px | Readable measure. |
| Marketing pages | 1100 to 1280px | Room for imagery and multi-column sections. |
| Application shells | Full width | Tools use available space; content columns are constrained inside. |
| Data tables | Full width with horizontal scroll | Truncating columns is worse than scrolling. |
| Forms | 480 to 640px | Single column, comfortable field width. |
Container queries
.card-host { container-type: inline-size; container-name: card; }
.card { display: grid; gap: var(--space-3); }
@container card (min-width: 28rem) {
.card {
grid-template-columns: 8rem 1fr;
align-items: start;
}
}The component adapts to the space it is actually in, which makes it reusable in a sidebar and in a wide grid without variants.
Constraining width
Do
- Set a maximum width for text, and let backgrounds run full bleed.
- Pick the constraint from the content type, not from a device width.
- Use container queries so a component adapts to its slot rather than the viewport.
- Keep horizontal padding responsive, so content never touches the edge.
Do not
- Let paragraphs run the full width of a wide monitor.
- Constrain a data table to a reading measure, which forces horizontal scroll for no reason.
- Use one container width for every page in the product.
In practice
- i.
Reusable card without variants
Design systemsOne card component that reflows based on its own width replaces a family of size variants and the documentation explaining when to use each.
- ii.
One card, three widths
What container queries changedThe same card sat in a sidebar, a two-column grid and a full-width list. Before container queries this meant three variants. After, it means one component that asks how much room it has.
Local chart
FND·041 · Region II · Grid C2
This entry and the entries it is stated to connect with. Each line is labelled with what the connection means.
Sources
Where a source establishes something narrower than the popular reading of it, the note says so.
- [1]
MDN Web Docs
Continue from here
Each link says what the connection is, so you can tell a principle from an alternative from a thing people mix this up with.
Short definition
The one-paragraph version, for when that is all you need.
- BreakpointTERM·044 · Term
- Container QueryTERM·070 · Term
- MeasureTERM·062 · Term
- Responsive DesignTERM·043 · Term
Related concept
Connected closely enough to change how you apply this.
- Reflow and ZoomA11Y·013 · Accessibility
- Component API DesignSYS·002 · Design system
- BreakpointsFND·045 · UI foundation
- ColumnsFND·040 · UI foundation
- Common RegionFND·006 · UI foundation
- CompositionFND·014 · UI foundation
- GridsFND·039 · UI foundation
- ReadabilityFND·036 · UI foundation
- Responsive LayoutFND·043 · UI foundation
- Responsive TypographyFND·038 · UI foundation