max-width
Sets the maximum width of an element. It prevents the element from becoming wider than the specified value, even if the content or container is larger.
It is documented as part of the CSS Box Sizing specification.
Syntax
/* Usage Example */
.article-content {
width: 100%;
max-width: 800px;
margin: 0 auto;
/* keeps text lines at a readable length on large screens */
}
/* Syntax */
max-width: none;
max-width: length-percentage;
max-width: min-content;
max-width: max-content;
max-width: fit-content;
max-width: calc-size;
max-width: anchor-size;
/* Global values */
max-width: inherit;
max-width: initial;
max-width: revert;
max-width: revert-layer;
max-width: unset;
max-width Browser support
Widely available
Since
2015 96% global usage
This feature is well established and works across many devices and browser versions. It has been available across browsers since 2015.
1+
1+
1+
12+