spacing

max-width

Caps how wide an element can grow, overriding width when the two conflict. Essential for readable line lengths and responsive containers.

max-width: none | <length> | <percentage> | min-content | max-content | fit-content

Common values

Value Effect
none No maximum; element can grow indefinitely
100% Never wider than the parent
1200px Typical page container cap
65ch Comfortable prose measure
min-content Cap at intrinsic minimum content width

Examples

.prose { max-width: 65ch; }

Limits paragraphs to a readable line length

.container { max-width: 1200px; margin: 0 auto; }

Centered fixed-max page container

img { max-width: 100%; }

Prevents images from overflowing their container

Gotcha

max-width beats width when both are set; percentage max-width still needs a sized parent to resolve.

Related properties

← All CSS properties · CSS selectors · Grid vs Flexbox