Tested tool guide
Tested browser tools
Checked August 16, 2026
What CSS Aspect Ratio Box Generator does, with a checked example
Turn a ratio like 16:9 into ready-to-paste CSS for a responsive box whose height always follows its width, so an embedded video, an image placeholder, or a card stays proportional at every screen size. The tool emits two variants: the modern `aspect-ratio` property and the older padding hack, in which vertical padding creates the height. The number people most often stumble on is the padding percentage, because it is not the ratio itself: 16:9 needs 56.25%, since percentage padding is always calculated from the box's width, never its height.
Worked example
A concrete input and expected output from the current implementation.
->
Expected output
.ratio-box {
aspect-ratio: 16 / 9;
width: 100%;
}
/* padding hack variant */
.ratio-box {
position: relative;
height: 0;
padding-bottom: 56.25%;
}
.ratio-box > * {
position: absolute;
inset: 0;
} The modern variant takes the ratio directly. The hack must express the height ratio as a percentage of the width ratio, because vertical percentage padding is measured against the box's width: 9 divided by 16 is 0.5625, so the padding is 56.25%.