CSS max-width Property


Example

Set the maximum width of a <p> element:

p {
    max-width: 100px;
}

Try it yourself »

Definition and Usage

The max-width property is used to set the maximum width of an element.

This prevents the value of the width property from becoming larger than max-width.

Note: The value of the max-width property overrides width

Default value: none
Inherited: no
Animatable: yes, see individual properties. Read about animatable Try it
Version: CSS2
JavaScript syntax: object.style.maxWidth="600px" Try it

Browser Support

The numbers in the table specify the first browser version that fully supports the property.

Property
max-width 1.0 7.0 1.0 2.0.2 7.0

CSS Syntax

max-width: none|length|initial|inherit;

Property Values

Value Description Play it
none No maximum width. This is default Play it »
length Defines the maximum width in px, cm, etc.  Play it »
% Defines the maximum width in percent of the containing block Play it »
initial Sets this property to its default value. Read about initial Play it »
inherit Inherits this property from its parent element. Read about inherit

Related Pages

CSS tutorial: CSS Dimension

CSS reference: min-width property

HTML DOM reference: maxWidth property




SHARE THIS PAGE

COLOR PICKER

colorpicker