CSSKit

CSS Aspect Ratio Calculator | Free Online Tool - CSSKit

Free CSS aspect ratio calculator. Generate aspect-ratio property values, calculate dimensions from ratios, and preview responsive boxes.

Simplified Ratio: 16 : 9|Decimal: 1.7778|Padding Hack: 56.25%

400px
400px × 225px
.element {
  width: 100%;
  aspect-ratio: 16 / 9;
}

What is CSS Aspect Ratio Calculator?

CSS Aspect Ratio Calculator is a free online tool for generating CSS aspect-ratio property values. Enter dimensions or select presets to calculate ratios, preview responsive boxes, and copy production-ready CSS code.

How to Use CSS Aspect Ratio Calculator

Enter the desired width and height values, or select a common aspect ratio preset (16:9, 4:3, 1:1, etc.). The tool calculates the simplified ratio and generates the CSS aspect-ratio property. Adjust the container width to see how the height scales. Copy the generated CSS code.

How CSS Aspect Ratio Calculator Works

The tool takes width and height inputs, simplifies them to the smallest integer ratio using GCD, and generates the CSS aspect-ratio property. The live preview shows a box that maintains the chosen ratio at any container width, demonstrating how the property works in practice.

Common Use Cases

  • Setting responsive video container ratios
  • Creating consistent image placeholders
  • Building responsive card layouts
  • Calculating dimensions for design assets
  • Maintaining proportions in fluid layouts

Frequently Asked Questions

What is the CSS aspect-ratio property?

The CSS aspect-ratio property sets a preferred aspect ratio for an element, which will be used in the calculation of auto sizes. For example, aspect-ratio: 16/9 makes the element maintain a 16:9 ratio.

Is the aspect-ratio property supported in all browsers?

Yes, the CSS aspect-ratio property is supported in all modern browsers including Chrome 88+, Firefox 89+, Safari 15+, and Edge 88+.

What are common aspect ratios for video?

16:9 is the standard widescreen ratio used by YouTube and most video platforms. 4:3 is the classic TV ratio. 21:9 is ultrawide. 9:16 is vertical/portrait video.

How does aspect-ratio differ from the padding-bottom hack?

The aspect-ratio property is a modern, clean CSS solution. The padding-bottom percentage hack was the old workaround (e.g., padding-bottom: 56.25% for 16:9). The property is much simpler and more readable.

Related Tools