CSS max-width property
Browser support · legacy reference
ChromeFully supports
SafariFully supports
FirefoxFully supports
Internet ExplorerFully supports
EdgeFully supports
OperaFully supports
Description
CSS max-width specifies the maximum width of an element.
If the content overflows the width, it adds a scrollbar to the element.
Syntax
max-width : none | min-content | max-content | +ve length | +ver percentage | auto
Property values
min-content
-
min-content value specifies the largest minimum width of some descendant item.
- Try it
max-width: min-content; max-content
-
max-content value represents the largest maximum width of some descendant item.
- Try it
max-width: max-content; +ve percentage
-
30% means the width of current box can not exceed 30% of the parent box.
- Try it
max-width: 30%; auto
-
auto value means the width will be changed automatically according to the content.
- Try it
max-width: auto;
Applicable to
It applies to all elements