On this page
aspect-ratio
Prev: `padding` | Up: box_model | Next: `overflow`
Rel: box_model, Box Model & Sizing Guide
Ref: MDN Web Docs — aspect-ratio
Tags: #public #web #css #properties #box_model #tier/core
Syntax & Overview
aspect-ratio: 16 / 9;
Declares a preferred width-to-height ratio for responsive boxes and media.
- Initial:
auto| Inherited: No | Animatable: Yes
Notes & Best Practices
- Prevents Cumulative Layout Shift (CLS) on responsive images, videos, and cards.
- Pair with
object-fit: coveron<img>so images crop cleanly instead of distorting.
Example
.thumbnail {
width: 100%;
aspect-ratio: 16 / 9;
object-fit: cover;
}
Linked from
Related notes
- tuts/css/properties/box_model/overflow Linked here; links to this page; shared tags: #css, #properties, #tier, #web
- tuts/css/properties/box_model/padding Linked here; links to this page; shared tags: #css, #properties, #tier, #web
- tuts/css/properties/box_model Linked here; links to this page; shared tags: #css, #properties, #web
- tuts/css/properties/box_model_and_sizing Linked here; shared tags: #css, #properties, #web
- tuts/css/properties/box_model/box-sizing shared tags: #css, #properties, #tier, #web
- tuts/css/properties/box_model/inline-size shared tags: #css, #properties, #tier, #web
- tuts/css/properties/box_model/margin shared tags: #css, #properties, #tier, #web
- tuts/css/properties/layout/align-items shared tags: #css, #properties, #tier, #web
- tuts/css/properties/layout/display shared tags: #css, #properties, #tier, #web
- tuts/css/properties/layout/flex shared tags: #css, #properties, #tier, #web