You need a banner 1,200 pixels wide in the same shape as a 1920 × 1080 video. A client sends a photo that must fit a 4:5 slot. A video embed collapses to zero height on mobile, or an image stretches so faces look wider than they should. All of these are aspect ratio problems, and they come down to one simple relationship between width and height.
This guide explains what an aspect ratio is, how to simplify a resolution into a ratio, how to solve for a missing dimension, and how to keep proportions in CSS so layouts do not jump while images load.
What an aspect ratio is
An aspect ratio is the proportion between width and height, written W:H. A 1920 × 1080 screen and a 1280 × 720 video are both 16:9: different sizes, same shape. Resizing without distortion means changing the size while keeping that proportion.
You will also see ratios written as a single decimal, width divided by height. 16:9 is about 1.78, and 1.91:1 is the shape many social platforms use for link preview images. The decimal form is handy for comparing: anything above 1 is landscape, exactly 1 is square, below 1 is portrait.
How to simplify a resolution
To turn a pixel size into a ratio, divide both numbers by their greatest common divisor (GCD):
- 1920 and 1080 share a GCD of 120.
- 1920 ÷ 120 = 16 and 1080 ÷ 120 = 9.
- The ratio is 16:9.
In code, Euclid's algorithm finds the GCD in a couple of lines:
const gcd = (a, b) => (b === 0 ? a : gcd(b, a % b));
const ratio = (w, h) => {
const g = gcd(w, h);
return `${w / g}:${h / g}`;
};
console.log(ratio(1920, 1080)); // 16:9
console.log(ratio(1440, 900)); // 8:5
console.log(ratio(1366, 768)); // 683:384
The last example shows why the exact ratio is not always the name people use. 1366 × 768 laptops are sold as "16:9", but the maths gives 683:384, which is only approximately 16:9 (1.779 against 1.778). The same goes for "21:9" ultrawide monitors: 2560 × 1080 simplifies to 64:27 and 3440 × 1440 to 43:18. Marketing ratios are rounded; the pixels are what count.
Solving a missing dimension
When you know the ratio and one side, cross-multiply:
height = width × (ratio height ÷ ratio width)
width = height × (ratio width ÷ ratio height)
Examples:
- A 16:9 video 1280 pixels wide: 1280 × 9 ÷ 16 = 720 pixels high.
- A 4:5 portrait image 1080 wide: 1080 × 5 ÷ 4 = 1350 high.
- A 3:2 photo printed 30 cm wide: 30 × 2 ÷ 3 = 20 cm high.
The formula works in any unit, because a ratio has no unit.
Common ratios and where they appear
| Ratio | Decimal | Typical use |
|---|---|---|
| 16:9 | 1.78 | HD and 4K video, most monitors and TVs |
| 9:16 | 0.56 | Vertical video such as stories and short-form clips |
| 4:3 | 1.33 | Older TVs and monitors, many tablets |
| 3:2 | 1.5 | 35mm film and many camera sensors |
| 1:1 | 1 | Square social posts, avatars |
| 4:5 | 0.8 | Portrait social feed images |
| 16:10 | 1.6 | Many laptop displays |
| 21:9 | about 2.33 | Ultrawide monitors, cinematic crops |
Platforms change their recommended sizes from time to time, so check the current official guidance before producing final artwork. The social media image sizes reference collects the usual dimensions in one place.
Use the calculator
The Aspect Ratio Calculator handles both directions: from a size to a ratio, and from a ratio to a size.
- Open the Aspect Ratio Calculator. Enter a ratio in Aspect ratio (W : H), such as 16 and 9, or click one of the Common ratios tiles (16:9, 9:16, 4:3, 3:2, 1:1, 4:5, 21:9, 16:10, 2:1 and 1.91:1).
- Under Size (px, cm, inches – any unit), type a width and the height is solved for you, or type a height to get the width.
- To find the ratio of an existing size, enter both numbers and click Get ratio from this size.
- Click Swap orientation to flip between landscape and portrait.
- Read the results: Simplified ratio, Decimal (W÷H) and Size, with a preview rectangle in the right shape.
- Copy the ready-made CSS line, for example
aspect-ratio: 16 / 9;.
Keeping proportions in CSS
The aspect-ratio property tells the browser an element's shape before its content loads, which prevents the page from jumping (a cause of poor Cumulative Layout Shift scores).
.video-frame {
width: 100%;
aspect-ratio: 16 / 9;
}
.video-frame iframe {
width: 100%;
height: 100%;
border: 0;
}
.product-photo {
width: 100%;
aspect-ratio: 4 / 5;
object-fit: cover;
}
For images, also put the real width and height attributes in your HTML (<img src="team.jpg" width="1600" height="900" alt="...">). Modern browsers use them to reserve the right space, and CSS width: 100%; height: auto; still makes the image responsive.
object-fit decides what happens when an image's own ratio differs from the box: cover fills the box and crops the overflow, contain shows the whole image with empty bands, and the default fill stretches it, which is where distorted faces come from.
Other ways to do it
- Image editors such as Photoshop, GIMP or the Photos app on most phones have a "constrain proportions" or lock icon when resizing. Leave it on.
- Spreadsheets solve dimensions easily: with a width in A2,
=A2*9/16gives the 16:9 height, and=GCD(A2,B2)helps simplify a ratio. - Resizing in the browser: once you know the target size, the image resizer scales to it, and the image cropper trims to a fixed ratio when the source is a different shape.
Pitfalls
Resizing versus cropping
Changing a 4:3 photo into 16:9 is impossible without either cropping, adding bars, or stretching. Decide which is acceptable before you start; for photos of people, cropping is usually the right answer.
Rounding
Solving a height often gives a fraction, such as 1200 × 9 ÷ 16 = 675 (exact) but 1000 × 9 ÷ 16 = 562.5. Pixels must be whole numbers, so round, or choose a width that divides evenly. Video encoders often prefer even numbers.
Pixel aspect ratio
Some older video formats use non-square pixels, so the stored resolution does not match the displayed shape. If a video looks squashed despite correct numbers, check its pixel or display aspect ratio in your video software.
Frequently asked questions
What is the formula for aspect ratio?
Divide width and height by their greatest common divisor. For 1920 × 1080, both divide by 120, giving 16:9.
How do I calculate height from width and a ratio?
Multiply the width by the ratio's height and divide by the ratio's width. For 16:9 at 1600 wide: 1600 × 9 ÷ 16 = 900.
Is 1920 × 1080 the same as 16:9?
Yes. 1920 × 1080, 1280 × 720 and 3840 × 2160 are all exactly 16:9.
What aspect ratio is 1080 × 1350?
It simplifies to 4:5, a common portrait format for social feeds.
Why does my video embed have no height?
Iframes do not know their content's shape. Give the wrapper width: 100% and aspect-ratio: 16 / 9 and make the iframe fill it.