CSS aspect-ratio Property

❮ Previous Reference Next ❯


img {
  aspect-ratio: auto;
  max-width: 100%;

something went wrong.


The aspect-ratio CSS property sets a preferred aspect ratio for the box, which will be used in the calculation of auto sizes and some other layout functions.

Default value:auto
JavaScript syntax:

Standard Syntax

aspect-ratio: auto|ratio|initial|inherit|revert|revert-layer|unset;

Browser Support


Property Values

The following table describes the values of this property.

Value Description
auto Replaced elements with an intrinsic aspect ratio use that aspect ratio, otherwise the box has no preferred aspect ratio. Size calculations involving intrinsic aspect ratio always work with the content box dimensions.
ratio The box's preferred aspect ratio is the specified ratio of width / height. If height and the preceding slash character are omitted, height defaults to 1. Size calculations involving preferred aspect ratio work with the dimensions of the box specified by box-sizing.
initial Sets this property to its default value.
inherit If specified, the associated element takes the computed value of its parent element animation-delay property.
revert Reverts the cascaded value of the property from its current value to the value the property
revert-layer Rollback styles to the ones specified in previous cascade layers.
unset Resets a property to its inherited value if the property naturally inherits from its parent, and to its initial value if not.

Default CSS Property Values

selectors {
  aspect-ratio: auto;
❮ Previous Reference Next ❯