Skip to content
Other

CSS Aspect Ratio Calculator

Enter a width and height in pixels and this calculator gives you the simplified ratio, the decimal value, the padding-bottom percentage for the classic responsive CSS trick, and the ready-to-copy modern CSS aspect-ratio property. Switch to "Find height" or "Find width" mode to solve for an unknown dimension. All results update as you type.

Your details

Choose whether to compute the ratio from pixel dimensions, or solve for a missing dimension given the ratio.
The width of the element in pixels.
px
The height of the element in pixels.
px
Simplified ratio
16:9

Width:height reduced to the lowest whole-number form.

Decimal ratio (w/h)1.7778
Padding-bottom56.25%
CSS aspect-ratio value16 / 9
Common name16:9 (HD Video / Widescreen)

Aspect ratio: 16:9 - 16:9 (HD Video / Widescreen)

  • This is the well-known 16:9 (HD Video / Widescreen) format, widely used in responsive web and video design.
  • The ratio is landscape (wider than tall), with a decimal value of 1.7778.
  • For the legacy CSS padding trick, set padding-bottom: 56.2500% on a container with height: 0.

Next stepUse aspect-ratio: 16 / 9; in modern browsers (all evergreen browsers support this). Fall back to the padding-bottom trick only if you need to support IE 11 or very old mobile browsers.

What is an aspect ratio in CSS?

An aspect ratio is the proportional relationship between an element's width and height, expressed as two whole numbers separated by a colon, such as 16:9 or 4:3. In web development, aspect ratios matter because a fixed pixel height breaks responsiveness: as the viewport narrows, the width shrinks but a hard-coded height stays the same, distorting the layout. Expressing the ratio instead of absolute dimensions lets the browser maintain proportions at any size. The modern CSS property aspect-ratio (available in all current browsers including Chrome, Firefox, Safari, and Edge since 2021) accepts this ratio directly, so a container with width: 100% and aspect-ratio: 16 / 9 always renders at the correct proportion.

The CSS padding-bottom trick explained

Before the aspect-ratio property was widely supported, developers used the "padding hack". When you set padding-bottom as a percentage on a block element, the browser calculates it as a percentage of the element's width, not its height. This creates a predictable height that scales with width. The formula is: padding-bottom (%) = (height / width) x 100. For a 16:9 container, that is (9 / 16) x 100 = 56.25%. The technique requires the container to have height: 0 and position: relative, with the inner content absolutely positioned to fill it. For new projects targeting modern browsers, use aspect-ratio directly. The padding trick remains useful for legacy browser support or when working with iframes such as YouTube or Vimeo embeds.

How to simplify a ratio to lowest terms

A simplified ratio removes common factors from both numbers so they share no divisor larger than 1. The tool uses the Euclidean algorithm to find the greatest common divisor (GCD) of the width and height, then divides both by it. For example, a 1920 x 1080 element has a GCD of 120, giving 1920/120 : 1080/120 = 16:9. This matters because CSS aspect-ratio expects the simplest whole-number form, and because recognising the ratio as 16:9 immediately tells you it is standard HD video. If your dimensions do not simplify to a recognisable small-number ratio, you can still use them directly in CSS: aspect-ratio: 1920 / 1080; is perfectly valid.

Solving for a missing dimension

When you know the target ratio and one dimension but need the other, the math is straightforward. To find the height: height = width x (ratio height / ratio width). For a 1280 px wide container at 16:9, height = 1280 x (9 / 16) = 720 px. To find the width: width = height x (ratio width / ratio height). This is useful when you have a fixed-height container and need to know how wide to make it, or when sizing video thumbnails and social media assets to exact pixel targets. Switch the "Solve for" input to the relevant mode and the calculator handles the arithmetic.

Common aspect ratios in web and media

RatioCommon namePadding-bottom %Typical use
1:1Square100.00%Profile photos, Instagram feed
4:3Standard75.00%Classic TV, presentations, tablets
3:2Classic Photo66.67%35mm film, DSLR sensors
16:9HD / Widescreen56.25%YouTube, HD video, laptop screens
16:10Wide Monitor62.50%MacBook, widescreen monitors
5:4SXGA80.00%Older monitors, print formats
21:9Ultra-wide42.86%Cinema, ultra-wide monitors
9:16Portrait177.78%Reels, TikTok, Stories
4:5Instagram Portrait125.00%Instagram portrait posts

The simplified ratio, its common name, and the padding-bottom percentage for the CSS trick.

Frequently asked questions

What is the difference between aspect-ratio in CSS and the padding-bottom trick?

The CSS aspect-ratio property (e.g., aspect-ratio: 16 / 9;) is the modern, direct approach supported in all current browsers. The padding-bottom trick is the legacy workaround: set height: 0 and padding-bottom to (height / width) x 100 percent on the container, which forces the browser to reserve the correct vertical space. Use the aspect-ratio property for new projects. Reserve the padding trick for environments where you must support IE 11 or very old browsers, or for iframes where the aspect-ratio property does not apply to the inner content.

How do I make a responsive video embed with the correct aspect ratio?

Wrap the iframe in a container div and apply the padding trick or modern property to the wrapper, then absolutely position the iframe inside it. For a 16:9 YouTube embed: set position: relative and padding-bottom: 56.25% on the wrapper, height: 0, then on the iframe set position: absolute; top: 0; left: 0; width: 100%; height: 100%. Alternatively, on modern browsers just set aspect-ratio: 16 / 9 on the wrapper (no padding hack needed) and width: 100% on the iframe.

Why does 1920 x 1080 simplify to 16:9?

Because both 1920 and 1080 share a greatest common divisor of 120. Dividing both by 120 gives 1920/120 = 16 and 1080/120 = 9, so the simplified ratio is 16:9. This is the standard HD and Full HD resolution and is the most common aspect ratio for video content and laptop displays.

Can I use a decimal or percentage instead of a whole-number ratio?

Yes. In CSS you can write aspect-ratio: 1.7778 or even aspect-ratio: 16 / 9; the browser accepts both. The padding-bottom value is inherently a percentage (56.25% for 16:9). However, the simplified whole-number form (16 / 9) is clearest to read and is the conventional format in CSS stylesheets.

What aspect ratio should I use for social media images?

It depends on the platform and format. Instagram feed posts work best at 1:1 (square) or 4:5 (portrait). Instagram and TikTok videos use 9:16. YouTube thumbnails and videos use 16:9. Facebook feed images and Twitter posts typically use 16:9 or 1:1. Always check the current platform guidelines because cropping rules change, but this calculator can generate the exact pixel dimensions once you have the target ratio and one known measurement.

Sources

Written by Grace Mbeki, MSc Data Scientist & Educator · Nairobi, Kenya

Turning everyday numbers into clear, actionable answers for the decisions that matter most.

Search 3,500+ calculators

Loading search…