Aspect ratio (CSS): plainly explained.

The aspect-ratio CSS property sets an element's width-to-height proportion. How it works, why it reduces layout shift (CLS), and the old padding hack.

Design · Updated Nov 7, 2026

DEFINITION

The aspect-ratio CSS property sets the width-to-height proportion of an element, keeping images and videos from distorting or shifting the layout.

CATEGORY

Design

RELATED

Responsive design, CSS Grid

Summarize this page with AI

The aspect-ratio CSS property sets the proportion between an element's width and height, for example 16 by 9 for a video or 1 by 1 for a square. The browser keeps that shape as the element resizes, which is essential for responsive images, videos, cards and embeds that must not distort or shift the layout.

01

How the property works

You write the ratio as two numbers separated by a slash. If only one dimension is set, the browser computes the other from the ratio.

  • aspect-ratio: 16 / 9; with width: 100%; gives a full-width 16:9 box.
  • aspect-ratio: 1; is shorthand for a perfect square.
  • A set height or an intrinsic content size can override the computed dimension, so pair it with a single fixed dimension for predictable results.
02

Common ratios

A small set of ratios covers most interfaces.

Ratio
16:9CSS value16 / 9Typical useVideo, hero media
4:3CSS value4 / 3Typical useClassic photos, slides
1:1CSS value1 / 1Typical useAvatars, square thumbnails
3:2CSS value3 / 2Typical usePhotography
21:9CSS value21 / 9Typical useUltrawide banners
03

Layout stability and Core Web Vitals

Reserving space with a fixed ratio prevents layout shift while an image or video loads. That directly improves Cumulative Layout Shift (CLS), one of the Core Web Vitals Google uses as a ranking signal, because the surrounding content does not jump when the media finally appears.

04

Using aspect-ratio with images

Set aspect-ratio plus a width on an image and add object-fit: cover; so the picture fills the box and crops instead of stretching. This keeps a gallery tidy even when source images have mixed dimensions, and it pairs well with the width and height attributes that let the browser reserve space before CSS loads.

05

The old padding hack and browser support

Before this property, developers faked ratios with a padding-top percentage trick and absolute positioning, which was verbose and easy to break. The native aspect-ratio replaces that with one clear line and is supported across all modern browsers, so the hack is no longer needed on current projects.

06

Aspect ratio at BeBranded

At BeBranded we lock media to consistent ratios so galleries and cards stay tidy and pages do not shift as they load, which protects both the design and the Core Web Vitals. It is part of the stable, polished front-end in our design work.

FAQ

Questions about Aspect ratio (CSS).

Another question?

Write to us
What is the aspect-ratio property?
The aspect-ratio CSS property sets the proportion between an element's width and height, so it keeps its shape as it resizes. It is used for responsive images, videos and cards.
How do you write an aspect ratio in CSS?
Write two numbers separated by a slash, for example aspect-ratio: 16 / 9. Common values are 16/9 for video, 4/3 for photos and 1/1 for squares.
Why does aspect-ratio help layout stability?
It reserves space for media before it loads, so surrounding content does not jump. This lowers Cumulative Layout Shift, one of the Core Web Vitals that affects SEO and user experience.
What was the old padding hack?
Before the property existed, developers faked ratios with a padding-top percentage and absolute positioning. The native aspect-ratio property replaces that with a single clear line.
Does aspect-ratio work on images?
Yes. Setting aspect-ratio with a width lets the browser compute the height and hold the shape. Combined with object-fit, it keeps images from distorting inside their box.
Does Webflow support aspect-ratio?
Yes. You can set an aspect ratio on elements in the Designer, or add it as a custom property, and it exports as the standard CSS aspect-ratio.

Related

Related terms, and where to go next.

How to easily create circular text on your Webflow site
Webflow

How to easily create circular text on your Webflow site

Discover how to add a creative touch to your website with circular text using the Figma "Arc" extension. Follow our guide to enhance your site.

Read the article
Illustration for the article “How to find the best website designer for your project”
Development

How to find the best website designer for your project

Find the best website designer for your project with a clear evaluation framework, practical checklist, common mistakes and FAQs.

Read the article
BeBranded
UX/UI

html.to.design: import any website into Figma

html.to.design converts any website into an editable Figma design. Benchmarks, redesigns, and HTML capture for AI-assisted development.

Read the article

Let’s talk

Tell us what you want to build.

Thirty minutes with the people who will work on your project. You leave with a clear view of the scope, the timeline and the next steps.

What happens next

  1. 1A 30-minute callWe listen to your goals, your constraints and your context.
  2. 2A clear scopeWe map what is worth doing first, and what it takes.
  3. 3A costed proposalYou decide, with no commitment and no sales pitch.