CSS aspect-ratio Property (No Padding Hack)
Aspect ratios without the padding hack
By Naeem Noor on Updated on
The old trick used padding-top: 56.25% and nested absolute positioning. aspect-ratio does it in one declaration.
The old hack vs the modern fix
View demoOld way8 lines
.video-wrapper {
position: relative;
padding-top: 56.25%;
}
.video-wrapper > * {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}2 lines
.video-wrapper {
aspect-ratio: 16 / 9;
}aspect-video
Example
<!-- aspect-video = 16/9, aspect-square = 1/1 --><div class="aspect-video">Video embed</div><div class="aspect-square">Profile photo</div><div class="aspect-[4/3]">Custom ratio</div>Aspect ratio browser support
BaselineWidely availableThis feature is well established and works across many devices and browser versions. It has been available across browsers since 2021.Safe to use without fallbacks.
Usage97%of people can use this3% use a browser without it.
Browsers
88+
89+
15+
88+Last checked 3 Dec 2026 · web-features 3.49.0
Live demo
three shapes, one property each
Why the modern way wins
No math
16/9, 4/3, 1/1. No percentage math or nested wrappers.
Single element
One container, one property. Content can sit inside without absolute positioning.
Any ratio
Use any ratio you need. Works with flex and grid too.
- Lines Saved
- 8 → 2
- 75% less code
- Old Approach
- Padding + absolute
- 56.25% for 16:9
- Modern Approach
- One property
- aspect-ratio: 16/9
How it works
The classic trick was a wrapper with padding-top: 56.25% (100/16*9 for 16:9) and position: relative, then a child with position: absolute; inset: 0 to fill it. Two selectors, magic numbers, and the child had to be taken out of flow.
aspect-ratio: 16 / 9 on the container does the job. The element keeps that ratio as width changes. No padding hack, no absolute child, no percentage math.