Dev Helpers

Tailwind CSS / Box model and sizing

Fluid width with a maximum

Dev Helpers · August 12, 2025

Combining full width with a maximum creates a panel that scales to its parent. Automatic margins can centre it after it reaches the cap.

Worked example

<div class="demo w-[min(100%,20rem)]">Fluid width with a maximum</div>

Implementation notes

The maximum applies to the element, while outer gutters usually belong to its parent. Avoid charging the same horizontal padding twice.

Try it yourself

Resize the parent independently from the browser.

Open the Tailwind CSS example →

Editorial date August 12, 2025 · Published December 6, 2026

Related articles

Maximum reading width

A max-width utility constrains a reading column even when its parent occupies the whole viewport. Font size still determines how many characters fit.

Content-box sizing

The box-content utility deliberately sizes the inner area. This can help when reproducing a measured content region with a separate frame.

Minimum inline size

Minimum width belongs to the element that must remain usable. A minimum on a parent can unnecessarily force the entire page to scroll.