Dev Helpers

CSS / Box model and sizing

Square aspect ratio

Dev Helpers · October 27, 2026

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

Worked example

<style>
  .demo {
    width: 6rem;
    aspect-ratio: 1;
  }
</style>
<div class="demo">Square aspect ratio</div>

Implementation notes

An image's intrinsic dimensions can affect the preferred ratio. Give the media a defined fitting area when all cards must remain square.

Try it yourself

Put both a portrait photo and a landscape photo in the same square.

Open the CSS example →

Editorial date October 27, 2026 · Published December 6, 2026

Related articles

Fluid width with a maximum

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

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.