max-width

The max-width CSS property sets the maximum width of an element. It prevents the used value of the width property from becoming larger than the value specified by max-width.

Example

Initial value none
Applies to all elements but non-replaced inline elements, table rows, and row groups

Syntax

  
max-width: 50em;
  

Values

Defines the max-width as an absolute value.
Defines the max-width as a percentage of the containing block's width.
No limit on the size of the box.
The intrinsic preferred max-width.
The intrinsic minimum max-width.
Uses the fit-content formula with the available space replaced by the specified argument, i.e. min(max-content, max(min-content, argument)).

Browser support

max-width1121741
fit-content467934411
max-content4679664411
min-content4679664411
stretch227915

We use cookies to improve your experience. Learn more in our Privacy policy.

×