Jake Archibald avatar Jake Archibald

Avoiding <img> layout shifts: aspect-ratio vs width & height attributes

Screenshot of “Avoiding <img> layout shifts: aspect-ratio vs width & height attributes”

Layout shifts are a real annoyance on most sites, so please, read this new gem from Jake, about preventing images layouut shifts the right way… or the right ways actually.

For over a decade, we had to use silly hacks to manually apply an aspect ratio, and then, bloody typical, two better solutions arrived at roughly the same time. They are CSS aspect-ratio, and width & height presentational hints.