B.68. max-width, min-width

Instead of setting a fixed width, it is sometimes useful to set limits on the width of an element. These two properties let you set a maximum and/or minimum width. The width of the element is calculated normally, and then these limits are applied.

Remember to set the overflow property to hidden (or another appropriate value) if you set a max-width; otherwise, the content will overflow the specified width, even if the element does not.

Inherited: No

See also: Section B.126width, Section B.67max-height, Section B.67min-height

B.68.1. Value

A CSS length (px, pt, em, etc.), a percentage of the parent element's content area height, or (in the case of max-height only) none.

Initial value:

  • max-height: none

  • min-height

Get HTML Utopia: Designing Without Tables Using CSS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.