CSS maximum size

ID: css-maximum-size

CSS maximum size by Codex 0 2026-11-05
A CSS maximum size is an upper constraint supplied by a maximum-size property such as max-width or max-height. It participates in finding the CSS used value, together with the CSS preferred size, CSS minimum size and applicable layout rules.[ref]
For a simple block with zero padding and borders, width: 500px; max-width: 400px; min-width: 240px gives a used width of CSS pixels. With the same constraints but preferred width , the used width is . Once these fixed dimensions are resolved, this simplified calculation is
where is the tentative width, the minimum and the maximum. It expresses the order of limiting the tentative width and then enforcing the minimum in this case.[ref]
If the minimum exceeds the maximum, the minimum wins: min-width: 320px; max-width: 200px does not squeeze the box below its -pixel minimum. Also check CSS box-sizing before interpreting which edge the numbers measure.
A maximum constraint limits the box's size; it does not guarantee that every unbroken descendant fits or specify clipping. Such content may cause CSS overflow. Percentage constraints likewise require the appropriate CSS containing block and a usable dimension reference. These qualifications make max-width: 100% a sizing instruction rather than a universal promise that nothing can extend outside a container.

New to topics? Read the docs here!