Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

CSS max-width property

CSS max-width property

Example

Set the maximum width of a paragraph:

p

{

max-width:100px;

}

Try it »


Property definition and usage

The max-width property sets the maximum width of an element.

Note: The max-width property does not include padding, borders, or margins!

Default value: none
Inherited: no
Version: CSS2
JavaScript syntax: object.style.maxWidth="100px"

Browser support

The numbers in the table indicate the first browser version that supports this property.

property
max-width 1.0 7.0 1.0 2.0.2 7.0

Attribute values

Value Description
none Default. Defines no limit on the maximum width of an element.
length Defines the maximum width value of an element.
% Defines a percentage maximum width based on the containing block-level object.
inherit Specifies that the value of the max-width property should be inherited from the parent element.

Related Articles

CSS Tutorial: CSS Dimension

CSS Reference Manual: min-width property