← Back to release summary

Compute img/video aspect ratio from width and height HTML attributes

Category
CSS
Type
New or changed feature
Status
Enabled by default (Chrome 79)
Intent stage
Prepare to ship

WPT details: https://wpt.fyi/results/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio.tentative.html?label=experimental&label=master&aligned (The Chrome version used by wpt is too old to show us passing)

Summary

Computes the aspect ratio of an image using the HTML width and height attributes so that it can be used for sizing an image using CSS before it loads.

Motivation

To correctly compute the final dimensions of an image (before it is fully loaded), this feature computes the aspect ratio from the HTML width and height attributes, so that it can be used to compute the final size when e.g. "width: 100%; height: auto;" is used in CSS. This avoids unnecessary relayouts when the image loads (compared to <img src="foo.jpg" style="width: 100%">

Standards & signals

Ecosystem

Docs: https://github.com/WICG/intrinsicsize-attribute/issues/16#issuecomment-500941775

Explainers: https://github.com/WICG/intrinsicsize-attribute/issues/16#issuecomment-500941775

View on chromestatus.com