Skip to main content

HTML Guide

CSS: “max-width”: “auto” is not a “max-width” value.

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.

This property can express a value in different units like px, em, % or ch, and keyword values, but auto is not an allowed value.

Some examples of valid values for max-width:

/* <length> value */
max-width: 3.5em;

/* <percentage> value */
max-width: 75%;

/* Keyword values */
max-width: none;
max-width: max-content;
max-width: min-content;
max-width: fit-content(20em);

/* Global values */
max-width: inherit;
max-width: initial;
max-width: revert;
max-width: unset;

Learn more:

Related W3C validator issues