css.properties

max-width

The max-width property sets the maximum width of an element.

Formal Syntax

none | <length-percentage [0,∞]> | min-content | max-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()> | stretch | fit-content | contain

See specification

JavaScript Access

// Access via element.style
element.style.maxWidth = 'none';

Logical Property Group

This property belongs to the max-size logical property group, which includes:

Browser Support

standard | MDN · Spec

FeatureChromeFirefoxSafariEdge
max-width11112
anchor-size12514726125
fit-content46941179
fit-content_function91
max-content46661179
min-content46661179
none11112
stretch1387138

Behind a Flag

Some browsers require enabling a flag or preference:

  • max-width: fit-content_function — firefox: #layout.css.fit-content-function.enabled (since 91)

Related Properties