Name

max-width

Values:

<length> | <percentage> | none | inherit

Initial value:

none

Applies to:

All elements except inline nonreplaced elements and table elements.

Inherited:

No.

Percentages:

Refer to the height of the containing block.

Computed value:

For percentages, as specified; for length values, the absolute length; otherwise, none.

Description:

The value of this property sets a maximum constraint on the width of the element. Thus, the element can be narrower than the specified value but not wider. Negative values are not permitted.

Example:

#sidebar img {width: 50px; max-width: 100%;}

Supported by:

Firefox, Internet Explorer 7+, Opera, Safari.

Get CSS Pocket Reference, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.