Visit Mozilla.org

CSS:max-width

From MDC

« CSS Reference

[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.

[edit] Syntax

max-width: <length> | <percentage> | none | -moz-max-content | -moz-min-content | -moz-fit-content | -moz-available

[edit] Values

  • none : the width has 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-content New in Firefox 3

[edit] Examples

View Live 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

[edit] See also

box model, max-height, -moz-box-sizing, width, min-width