Set the maximum width of a <div> element:
The maxWidth property sets or returns the maximum width of an element.
The maxWidth property has effect only on block-level elements or on elements with absolute or fixed position.
Note: The width of an element can never be greater than the value specified by the maxWidth property.
Tip: To set or return the minimum width of an element, use the minWidth property.
The maxWidth property is supported in all major browsers.
Return the maxWidth property:
Set the maxWidth property:
Value | Description |
---|---|
none | No limit on the width of the element. This is default |
length | Defines the maximum width in length units |
% | Defines the maximum width in % of the parent element |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Default Value: | none |
---|---|
Return Value: | A String, representing the maximum width of an element |
CSS Version | CSS2 |
Return the maximum width of a <div> element:
CSS tutorial: CSS Dimension
CSS reference: max-width property