Vitals 101
Vitals 101
@CoreVitals101

aspect-ratio: the modern fix for image CLS

You know CLS — Cumulative Layout Shift — loves jumping images. The classic fix is width and height attributes, but for responsive images that scale with the screen, there's a cleaner tool.

Think of it like telling the browser the shape of the box, even when you don't know the exact size yet. It reserves the right proportions, so nothing jumps when the image arrives.

1. In CSS, add aspect-ratio: 16 / 9 to your image (match your real ratio).
2. Set width: 100% and height: auto so it scales cleanly.
3. The browser now reserves correctly-shaped space upfront.

This pairs perfectly with width/height attributes — belt and suspenders.

This one's easier than it sounds, just two CSS lines.

Try this: apply it to one gallery image, reload on slow network, and watch the jump disappear.
This post was published in the Telegram channel Vitals 101 (@CoreVitals101). All its posts are on the channel page.
Open on Telegram

Latest posts in “Tools and infrastructure”

All channels in this category →

реклама в сети

Готовы запустить рекламу через сеть public.tg?

Новый оффер, продукт, GEO, кейс, событие или партнёрский запуск — соберём маршрут под задачу и отдадим медиаплан.

Telegram для медиаплана: @AFFtop_connect. Быстрый тест: $20 за канал, $1000 за пакет по сети.