UTILS.
Private by default
▭

CSS Aspect Ratio Box

Generate a responsive aspect-ratio box with a padding fallback.

Your files stay on this device

Files are processed in your browser, never uploaded. The site downloads code and assets to run the tools. No accounts or trackers.

Use Download to save this tool as one HTML file for offline use.

Privacy →

About this tool

Enter a width and height ratio to generate a responsive aspect-ratio box, with both the modern aspect-ratio CSS and a padding-top percentage fallback, all in your browser.

Decimals are allowed (a comma also works). Up to six decimal places are scaled to whole numbers before reducing, so 2.35 by 1 gives 47 / 20. The fallback sets padding-top to height over width as a percentage rounded to three decimals (56.25% for 16 by 9) and stretches any direct child with position: absolute and inset: 0. Zero, negative or non-numeric entries show an invalid message.

Frequently asked questions

Why include a padding-top fallback?
The padding-top percentage trick reproduces a fixed aspect ratio in older browsers that do not support the modern aspect-ratio property.
Is the ratio simplified?
Yes — values like 16 and 9 are reduced by their greatest common divisor, so 1920 by 1080 is shown as 16 / 9.
Can I enter decimals like 2.35?
Yes; 2.35 by 1 is written as 47 / 20.
Where does my content go in the fallback?
As a direct child of .box-fallback, which is absolutely positioned to fill the box.

More tools