MDN self-hosted library · e01.org

`container` CSS property

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

css
/* <container-name> */
container: my-layout;

/* <container-name> / <container-type> */
container: my-layout / size;

/* Global Values */
container: inherit;
container: initial;
container: revert;
container: revert-layer;
container: unset;
html
<div class="post">
  <div class="card">
    <h2>Card title</h2>
    <p>Card content</p>
  </div>
</div>
css
.post {
  container-type: inline-size;
  container-name: sidebar;
}
css
.post {
  container: sidebar / inline-size;
}
css
@container sidebar (width >= 400px) {
  /* <stylesheet> */
}