CSS max-width Property

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 propertiesRead about animatable – Try it
Version: CSS2
JavaScript syntax: object.style.maxWidth=”600px” Try it
CSS Syntax
max-width: none|length|initial|inherit;
Property Values
Value Description
none No maximum width. This is default
length Defines the maximum width in px, cm, etc.
% Defines the maximum width in percent of the containing block
initial Sets this property to its default value. Read about initial
inherit Inherits this property from its parent element. Read about inherit