3 ms·
Include height and width attributes to your <img> tag and the layout shift problem is solved. Those are used to determine the aspect ratio, so even when resize
by Tomte 5y ago
Include height and width attributes to your <img> tag and the layout shift problem is solved.
Those are used to determine the aspect ratio, so even when resized via CSS the browser knows how much space to reserve in the layout.
- klodolph 5y agoThey are used to determine the intrinsic size. The aspect ratio is also affected by the CSS rules, and doesn't necessarily equal the aspect ratio of the intrinsic size.
- jacobr 5y agoThe width and height attributes are used by the browser to determine the aspect ratio https://www.smashingmagazine.com/2020/03/setting-height-width-images-important-again/ https://www.smashingmagazine.com/2020/03/setting-height-widt...
- klodolph 5y agoThat's a simplification--they determine the intrinsic size. The aspect ratio is determined by a combination of CSS rules and the intrinsic size.