Skip to content
gohacks.dev
Web

Aspect Ratio Calculator

Find the aspect ratio of any width and height, the closest common ratio, the height for a new width, and the CSS aspect-ratio value.

Free · No sign-up · Your inputs stay in your browser

Input

Calculate aspect ratios and resized dimensions

Output

16:9

Decimal ratio

1.7778

Closest common ratio: 16:9

Height at width 1280

720px

CSS

aspect-ratio: 16 / 9;

Padding hack (legacy)

padding-top: 56.2500%;

The CSS aspect-ratio property reserves the box's height before an image or video loads, so the page does not jump (cumulative layout shift). For images, width and height attributes on the img tag do the same: browsers compute the ratio from them.

Runs in this browser. Nothing you paste is sent to a server.

Prevent layout shift

When an image or embed loads without reserved space, the content below jumps, which Core Web Vitals measures as cumulative layout shift. width and height attributes on an img let the browser compute the ratio before loading; for other boxes, the aspect-ratio property reserves the space.

Common ratios

16:9 for video, 16:10 for many laptop screens and covers, 1.91:1 for Open Graph link images, 4:5 and 9:16 for portrait social posts.

Share

Frequently asked questions

How do I calculate the height for a given width?
Divide the width by the ratio: for 16:9 at 1280 wide, 1280 / (16/9) = 720.
Is the padding-top trick still needed?
No. Every current browser supports aspect-ratio. The padding percentage is only for very old browsers.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools