How do you make embedded content preserve its aspect ratio?

Use the CSS aspect-ratio property on a responsive wrapper or the embedded element itself. Give it a fluid inline size and let the browser calculate height from the ratio. This replaces older padding-percentage hacks for most video, iframe and media embeds.
.embed {
inline-size: 100%;
aspect-ratio: 16 / 9;
}
.embed iframe,
.embed video {
inline-size: 100%;
block-size: 100%;
border: 0;
}
Use the source’s real ratio because many videos and embeds are not 16:9. Maps, documents and interactive tools may need a minimum height as well as a ratio because their controls become unusable when the container is too short. Let the wrapper grow when captions or adjacent controls sit inside it.
Images and videos with intrinsic dimensions can establish their own aspect ratio when width and height attributes are present. Those attributes also reserve space before the asset loads, reducing layout shift. CSS can still override the rendered dimensions while preserving the intrinsic relationship.
Test narrow containers, full-screen controls and orientation changes. If an iframe’s internal page is not responsive, the outer ratio cannot repair it. The provider must support the assigned size, and keyboard focus inside the embed must remain visible without nested scrolling traps. Test the finished component with keyboard focus, touch input and a resized desktop window. Responsive geometry works only when controls stay reachable and the visual sequence matches the document order. Verify the behavior across the full width range, including spaces between design breakpoints. Long labels, translated copy and enlarged text can expose constraints that short sample content never reaches.