How the aspect-ratio property behaves
The aspect-ratio property lets a box be sized from a single declaration, which existing aspect-ratio techniques—including the custom-properties approach—don't offer. It is distinct from the media query aspect-ratio. Its sizing rules follow from a few core behaviors.
Height derived from an auto width
On its own, aspect-ratio calculates a height from the element's natural auto width: without an explicit width, the rendered width still exists, and the height follows from the ratio.
.el {
aspect-ratio: 16 / 9;
}

Content can override the ratio
If content grows beyond the aspect ratio, the element expands and the ratio is ignored—the same protection against data loss and overlap that made the pseudo-element tactic popular.
Adding min-height: 0; constrains the height to the ratio instead:

One dimension set, the other calculated
When the element has either a height or a width, aspect-ratio determines the other dimension. It is essentially a way of setting one direction from the other.

When both height and width are declared, the explicit pair is "stronger" than the ratio and aspect-ratio is ignored.

min-* and max-* constraints
The usual tension applies: width and min-width/max-width compete, and one always wins. Setting width: 100px; with min-width: 200px; lets min-width win; setting width: 100px; with max-width: 50px; lets max-width win. Either a min- or max- property is irrelevant, or it wins—and when it wins, it breaks the aspect-ratio.
.el {
aspect-ratio: 1 / 4;
height: 500px;
/* Ignored, because width is calculated to be 125px */
/* min-width: 100px; */
/* Wins, making the aspect ratio 1 / 2 */
/* min-width: 250px; */
}
Interaction with value functions
Fluid situations, where one dimension isn't known ahead of time, are where aspect ratios matter most—yet constraints still apply. A width of max(50%, 200px); or clamp(200px, 50%, 400px); behaves intuitively with the ratio.
.el {
aspect-ratio: 4 / 3;
width: clamp(200px, 50%, 400px);
}
If that 200px minimum is reached and a min-width: 300px; is also applied, the min-width wins. The outcome is still intuitive but becomes complex as more properties, functions and values combine.
A mental model: the weakest sizing signal
The simplest way to reason about aspect-ratio may be to treat it as the weakest way to size an element: it never overrides any other sizing information, but it always sizes a dimension that has no other information available.



