Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

CSS max-width property


May 05, 2021 CSS Reference Manual


Table of contents


CSS max-width property


Set the maximum width of the paragraph:

p
{
max-width:100px;
}

Try it out . . .

Description of property definition and use

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

Note: Max-width properties do not include padding, borders, or margins!

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


Browser support

The numbers in the table support the first browser version number of the property.

Attributes
max-width 1.0 7.0 1.0 2.0.2 7.0

The property value

Value Describe
none Default. The definition has no limit on the maximum width of the element.
length Defines the maximum width value of an element.
% Defines the maximum width based on the percentage of block-level objects that contain it.
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