concept

preferred-aspect-ratio — CSS reference

A preferred aspect ratio influences an auto dimension but does not force both explicitly sized dimensions to change. On a replaced element, auto plus a ratio uses its natural ratio when available; otherwise the supplied ratio applies. For a non-replaced element the supplied ratio is used.

Formal Syntax & Structure

css syntaxcss
aspect-ratio: auto 1 / 1

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>CSS sizing and overflow lab</title><style>body {margin:0} .sample {background:#dcebe9;color:#182e32}#a{display:block;width:100px;aspect-ratio:auto 1 / 1} #b{width:100px;aspect-ratio:auto 1 / 1}</style><body><img id="a" alt="Teal rectangle" src="data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%27120%27 height=%2760%27%3E%3Crect width=%27120%27 height=%2760%27 fill=%27teal%27/%3E%3C/svg%3E"><div id="b" class="sample"></div></body></html>
CSS Reference