English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
max-The maximum width of the content area of the element specified by the width CSS property. This maximum width does not include padding, border, or margin.-Please refer toCSS box model.
The following table provides usage instructions and version history of this attribute, as well as the syntax of using this attribute in JavaScript scripts.
Default value: | none |
---|---|
Applies to: | All elements except for unreplaced embedded elements, table rows, and row groups |
Inheritance: | No |
Animatable: | Yes.Please refer to Animation properties. |
Version: | CSS 2,3 |
JavaScript syntax: | object.style.maxWidth="200px" |
The syntax of this attribute is as follows:
max-width: length | percentage | none | initial | inherit
The following examples demonstrate how to use max-width attribute.
p { max-width: 400px; } div { width: 300px; max-width: 200px; }Test and see‹/›
The following table describes the value of this property.
Value | Description |
---|---|
length | The specified maximum width, in px, pt, cm, em, etc. Negative values are not allowed. |
percentage | Maximum width, in percentage. The percentage is calculated relative to the width of the element's containing block. Negative percentage values are not allowed. |
none | No maximum width. This is the default value. |
initial | Set this property to its default value. |
inherit | If specified, the associated element adopts the max of its parent element.-The value of the width property. |
max-Browser compatibility of the width attribute; the numbers in the table below represent the minimum version number of browsers that support this attribute; all mainstream browsers support this attribute.
|
Please refer to the tutorials related to the following content:CSS Box Model,CSS dimensions.