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.

Quick example

.article-content {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  /* keeps text lines at a readable length on large screens */
}

Quick facts

Initial value
none
Inherited
No
Applies to
all elements but non-replaced and table rows
Animation type
lpc

Values

nonelength-percentagemin-contentmax-contentfit-contentcalc-sizeanchor-size

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.

Safe to use without fallbacks.

1+
1+
1+
12+
ESC