Dev Helpers
← Back

Respond to the width of a container

Respond to the width of a container with native CSS. The preview includes a small shared demo stylesheet.

Open this example in the interactive library

Source code

<style>
  .demo {
    container-type: inline-size;
  }
  @container (min-width: 14rem) {
    .tile {
      display: inline-block;
      font-weight: 700;
    }
  }
</style>
<div class="demo">
  <span class="tile">Bold when the container has room</span>
</div>