CSS:max-width
From MDC
[edit] Summary
The max-width property is used to set the maximum width of a given element. It prevents the used value of the width property from becoming larger than the value specified for max-width.
- Initial value:
none - Applies to: block level and replaced elements
- Inherited: no
- Percentages: refer to the width of the containing block
- Media:
visual - Computed value:
[edit] Syntax
max-width: <length> | <percentage> | none | -moz-max-content | -moz-min-content | -moz-fit-content | -moz-available
[edit] Values
- none : the
widthhas no maximum value - length : can be in px, cm, in
- percentage : % specified as a percentage of containing block's width
- -moz-max-content : the intrinsic preferred width New in Firefox 3
- -moz-min-content : the intrinsic minimum width New in Firefox 3
- -moz-available : the containing block width minus horizontal margin, border, and padding New in Firefox 3
- -moz-fit-content : the same as
-moz-max-contentNew in Firefox 3
[edit] Examples
table{max-width: 75%;}
form{max-width: none;}
[edit] Notes
max-width overrides width, but min-width overrides max-width.
[edit] Specifications
[edit] Browser compatibility
| Browser | Lowest Version |
|---|---|
| Internet Explorer | 6 |
| Netscape | 6 |
| Opera | 3.5 |