# Aspect Ratio Box

> Locks any element to a 16:9 ratio, perfect for video embeds and image placeholders.

- Category: [CSS Layouts](https://copy-css.com/category/layouts)
- Tags: aspect-ratio, video, responsive, embed, media
- Live preview: https://copy-css.com/snippets/aspect-ratio-box
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<div class="ratio-box">16 : 9</div>
```

## CSS

```css
.ratio-box {
  aspect-ratio: 16 / 9;
  width: 100%;
}

/* Make embedded media fill the box */
.ratio-box > iframe,
.ratio-box > img,
.ratio-box > video {
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: cover;
}
```

## Notes

- This CSS Aspect Ratio Box is 14 lines of pure CSS (0.2 KB) with no JavaScript and no dependencies. It uses aspect-ratio.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
