Dev Helpers

CSS / Box model and sizing

Fluid width with a maximum

Dev Helpers · December 4, 2026

A fluid container needs a small-screen width and a large-screen maximum. Outer gutters should remain visible at both extremes.

Worked example

<style>
  .demo {
    width: min(100%, 20rem);
  }
</style>
<div class="demo">Fluid width with a maximum</div>

Implementation notes

Maximum width does not centre a container by itself. Inspect the remaining inline space and decide which margins should absorb it.

Try it yourself

Check a width slightly below the maximum and one well above it.

Open the CSS example →

Editorial date December 4, 2026 · Published December 6, 2026

Related articles

Square aspect ratio

A square ratio reserves equal sides even before media loads. Fit rules decide whether rectangular content is cropped or letterboxed.

Minimum inline size

A logical minimum inline size protects a component from collapsing beyond its usable width. An overly large minimum can force overflow.

Minimum block height

Minimum block size reserves space along the writing mode's block axis. Content can still make the element grow.