CSS max-width property

Examples

Setting the maximum width of the paragraph:

p
{
max-width:100px;
}


Attribute definitions and instructions

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

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

Defaults: none
inherit: no
version: CSS2
JavaScript syntax: object .style.maxWidth = "100px"


Browser Support

Figures in the table represent the first browser to support the version number of the property.

属性
max-width 1.0 7.0 1.0 2.0.2 7.0

Property Value

value description
none default. There is no limit on the definition of the maximum width of the element.
length The maximum width value defines the element.
% Definition is based on the percentage of the containing block-level object maximum width.
inherit Provisions should inherit the value max-width attribute from the parent element.


related articles

CSS tutorial: CSS a Dimension

CSS Reference: min-width attribute