The max-width property sets the maximum horizontal width of an element. It stops the used width from growing past the value you set.
The box can stay narrower than the limit. It cannot grow wider once it hits the ceiling. Pair it with min-width for a floor. For writing-mode-aware sizing, see max-inline-size.
Standard-track.
Not deprecated. Length, percentage, and none are Baseline. Intrinsic keywords (fit-content, max-content) are widely supported; stretch is newer and limited.
Limited support stretch
The stretch keyword for max-width is not ready for everyday use. Prefer lengths, percentages, or none.
Leave the default.none means no horizontal ceiling.
Add a ceiling.12rem stops growth at that width.
Text still wraps. The capped box wraps words instead of becoming wider.
Remember min-width. If min-width is larger than the max, the min wins.
Edge Cases & Pitfalls
If the cap seems ignored, one of these is usually why.
auto
auto is not valid
Unlike width, max-width does not accept auto. Use none to remove the ceiling.
override
max-width beats width
max-width overrides width when both apply. min-width overrides max-width if the min is larger.
logical
Always horizontal, not logical
max-width always limits physical width. Prefer max-inline-size when writing mode may change.
inline
Non-replaced inlines ignore it
A plain span does not take max-width. Use a block, flex item, or replaced element.
a11y
Tight caps can hurt zoomed text
When users enlarge text, a tight max may feel cramped. Prefer flexible units like rem or ch for text columns.
Compatibility
Browser Support
max-width is a browser layout property. Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
max-width
Length, percentage, and none work everywhere. Intrinsic keywords are widely supported; stretch is newer and limited.
99%Common values
Google Chrome1+
Full
Mozilla Firefox1+
Full
Apple Safari1+
Full
Microsoft Edge12+
Full
OperaSupported
Full
Samsung InternetSupported
Full
Internet Explorer7+
Full
max-widthWidely supported
Bottom line: Safe for everyday ceilings. Treat stretch as progressive enhancement until support is broad.
Remember
Key Takeaways
Role: set a ceiling on how wide a box can grow.
Common values:none, lengths, and percentages.
Initial value:none. Not inherited. auto is invalid.
Responsive pattern:width: 100% plus a max-width cap.
One line:max-width is a horizontal ceiling — the box can be narrower, never wider than the limit.
Frequently Asked Questions
It sets a maximum horizontal width for an element. The box can be narrower than the limit, but it cannot grow wider once it reaches that ceiling.
The initial value is none, which means there is no maximum width. The element can grow with its content and container.
width sets a preferred or fixed size. max-width only sets an upper limit. The box can still shrink below the max when the container is narrower.
Yes. max-width overrides width when the preferred width is larger. min-width overrides max-width if they conflict.
No. auto is not valid for max-width. Use none to remove the cap, or a length or percentage to set one.
It is Baseline and widely available in all major browsers. Newer keywords like stretch have limited support. It is a browser layout property, not a Node.js feature.