16:9 video box without the padding hack
Before aspect-ratio, developers reserved height with padding-top: 56.25% on a wrapper. Modern browsers accept aspect-ratio: 16 / 9 directly. This tool presets widescreen, 4:3, square, 9:16 story, 21:9 ultrawide, or custom integers up to 32 per side.
aspect-ratio versus padding-bottom percentage
Percentage padding still works in older codebases but fights flex and grid sizing. Aspect-ratio participates in auto layout like width and height. Copied CSS also includes width: 100% and object-fit: cover so photos and videos fill the frame without stretching oddly—swap object-fit if you need letterboxing.
| Preset | Copied ratio |
|---|---|
| Widescreen | 16 / 9 |
| Story | 9 / 16 |
| Ultrawide | 21 / 9 |
Does aspect-ratio work on inline elements?
It applies to block and replaced elements best. Make the media wrapper display: block or flex item before expecting ratio to hold.