<ul>
  <li><span></span></li>
  <li><span></span></li>
  <li><span></span></li>
  <li><span></span></li>
  <li><span></span></li>
</ul>
// Create as container
li {
  contain: layout inline-size;
}

// !important only needed since we are breaking the cascade for the sake of this demo to highlight the container query related rules
@container (min-width: 45ch) {
  li span {
    --color: var(--color2);

    &::after {
      content: "medium" !important;
      font-size: 2rem !important;
    }
  }
}

@container (min-width: 70ch) {
  li span {
    --color: var(--color3);

    &::after {
      content: "large" !important;
      font-size: 3rem !important;
    }
  }
}

// Demo layout styles
* {
  box-sizing: border-box;
}

:root {
  --saturation: 95%;
  --lightness: 80%;
  --color1: 80;
  --color2: 200;
  --color3: 260;
  --color: var(--color1);
  --dark: calc(var(--lightness) - 60%);
}

ul {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  list-style: none;
  margin: 0 auto;
  padding: 1rem;
  width: min(120ch, 100vw - 2rem);
}

li {
  flex: 1 1 30ch;

  span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 30vh;
    border-radius: 1rem;
    border: 2px dashed hsl(var(--color), var(--saturation), var(--dark));
    background-color: hsl(var(--color), var(--saturation), var(--lightness));
    color: hsl(var(--color), var(--saturation), var(--dark));

    &::after {
      content: "small";
      font-size: 1.5rem;
      letter-spacing: 0.03em;
    }
  }
}
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.