MDN self-hosted library · e01.org

`<ratio>` CSS type

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

css
@media screen and (aspect-ratio >= 16/9) {
  /* … */
}
css
@container (aspect-ratio > 1) and (width < 20em) {
  /* … */
}
css
.square {
  aspect-ratio: 1 / 1;
}
.circle {
  aspect-ratio: 1;
  border-radius: 50%;
}
.portrait {
  aspect-ratio: 5 / 7;
}