Easy Tutorial
❮ Dom Obj Frame Dom Obj Col ❯

Style maxWidth Property


Definition and Usage

The maxWidth property sets or returns the maximum width of an element.

The maxWidth property only works on block-level elements or elements with absolute/fixed positioning.

Note: The width of an element can never be greater than the value specified by the maxWidth property.

Syntax

Setting the maxWidth property:

Returning the maxWidth property:

Value Description
none Default. The element has no maximum width limit.
length Defines the maximum width using units like px, cm, etc.
% Defines the maximum width as a percentage of the parent element.
inherit The value of the maxWidth property is inherited from the parent element.

Browser Support

All major browsers support the maxWidth property.

Note: IE7 and earlier versions do not support the "inherit" value. IE8 supports "inherit" only if !DOCTYPE is specified. IE9 supports "inherit".


Example

Setting the maximum width of an element:

❮ Dom Obj Frame Dom Obj Col ❯