<!-- for article: https://utilitybend.com/blog/love-at-first-slide-creating-a-carousel-purely-out-of-css -->
<div class="wrapper">
  <div class="carousel">
    <div>
      You
    </div>
    <div>
      +
    </div>
    <div>
      <span>HTML</span>
    </div>
    <div>
      I
    </div>
    <div>
      ♡
    </div>
    <div>
      <svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 1000 1000" aria-labelledby="css-logo-title css-logo-description">
        <path fill="#639" d="M0 0h840a160 160 0 0 1 160 160v680a160 160 0 0 1-160 160H160A160 160 0 0 1 0 840V0Z" />
        <path fill="#fff" d="M358.1 920c-64.23-.06-103.86-36.23-103.1-102.79V648.82c0-33.74 9.88-59.4 29.64-76.96 35.49-34.19 117.83-36.27 152.59.52 21.42 18.89 29.5 57.48 27.58 93.49h-73.72c.56-14.15-.19-35.58-8.51-43.65-10.81-14.63-39.36-12.91-46.91 2.32-4.64 8.26-6.96 20.49-6.96 36.67v146.18c0 30.65 10.65 46.15 31.96 46.49 9.96 0 17.53-3.62 22.68-10.85 7.19-8.58 8.31-27.58 7.73-41.32h73.72c5.04 70.07-36.32 119.16-106.71 118.29Zm234.04 0c-71.17.98-103.01-49.66-101.04-118.29h69.59c-1.93 29.92 8.35 57.17 32.99 55.27 10.99 0 18.73-3.44 23.2-10.33 8.5-12.59 10.09-48.95-2.06-63.02-8.49-13.55-39.03-25.51-55.16-33.57-23.03-11.02-39.61-24.1-49.75-39.26-22.87-33.64-20.75-107.48 11.34-137.4 31.18-36.92 112.61-38.62 143.82-.77 19.25 19.51 27.66 57.9 26.03 93.23h-67.02c.57-14.52-.8-37.95-6.44-46.49-3.95-7.23-11.43-10.85-22.42-10.85-19.59 0-29.38 11.71-29.38 35.12.21 24.86 9.9 35.06 32.48 45.45 29.24 11.36 66.42 30.76 79.9 54.24 40.2 71.54 12.62 180.82-86.09 176.65Zm224.76 0c-71.17.98-103.01-49.66-101.04-118.29h69.59c-1.93 29.92 8.35 57.17 32.99 55.27 10.99 0 18.73-3.44 23.2-10.33 8.5-12.59 10.09-48.95-2.06-63.02-8.49-13.55-39.03-25.51-55.16-33.57-23.03-11.02-39.61-24.1-49.75-39.26-22.87-33.64-20.75-107.48 11.34-137.4 31.18-36.92 112.61-38.62 143.82-.77 19.25 19.51 27.66 57.9 26.03 93.23h-67.02c.57-14.52-.8-37.95-6.44-46.49-3.95-7.23-11.43-10.85-22.42-10.85-19.59 0-29.38 11.71-29.38 35.12.21 24.86 9.9 35.06 32.48 45.45 29.24 11.36 66.42 30.76 79.9 54.24 40.2 71.54 12.62 180.82-86.09 176.65Z" />
      </svg>
    </div>
    <div>
      Keep
    </div>
    <div>
      The Web
    </div>
    <div>
      <span>Stylish</span>
    </div>
  </div>
</div>

<!-- for demo purpose -->
<div class="warning">This is an experimental demo for scroll markers made in Chrome Canary, Your browser does not support scroll markers</div>
@import url("https://fonts.googleapis.com/css2?family=Barrio&family=Kablammo&family=Rubik+Puddles&display=swap");

@layer base, carousel, carouselItemsAndMarkers, carouselArrows, squareStyles;

@layer carousel {
  .carousel {
    width: 60vmin;
    anchor-name: --carousel;
    position: relative;
    margin: 0 auto;
    padding: 0;
    overflow: scroll;
    display: grid;
    container-type: inline-size;
    grid-template-columns: repeat(3, 100%);
    max-width: 100%;
    margin-right: auto;
    margin-left: auto;
    scroll-behavior: smooth;
    scroll-snap-type: both mandatory;
    overscroll-behavior: contain;
    scroll-marker-group: after;
    aspect-ratio: 1;
    scrollbar-width: none;

    /*     This styles the scorllmarker group, containing the scrollmarkers that hang on the carousel's items */
    &::scroll-marker-group {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      width: 105px;
      aspect-ratio: 1;
      margin: 80px auto 0;
      gap: 12px;
      align-items: center;
      justify-content: center;
      padding: 3vmin;
      border-radius: 10px;
      background: rgb(255 255 255 / 0.3);
      backdrop-filter: blur(1px);
      content: "";
    }
  }
}

@layer carouselItemsAndMarkers {
  .carousel > * {
    display: flex;
    justify-content: center;
    align-items: center;
    scroll-snap-stop: always;
    aspect-ratio: 1;
    scroll-snap-align: start;
    height: 100%;

    /*     scroll-markers are attached to the items themselves */
    &::scroll-marker {
      content: "";
      aspect-ratio: 1;
      width: 24px;
      border-radius: 50%;
      border: 1px solid silver;
      cursor: pointer;
      background: transparent;
      justify-content: center;
      transition: background 0.5s ease-out;
      border-color: currentColor;
    }

    /*     use target-current to see if the item is active or not */
    &::scroll-marker:target-current {
      background: inherit;
    }
  }
}

@layer carouselArrows {
  .carousel {
    &::scroll-button(inline-end),
    &::scroll-button(inline-start),
    &::scroll-button(block-start),
    &::scroll-button(block-end) {
      cursor: pointer;
      position: absolute;

      position-anchor: --carousel;
      inline-size: 30px;
      background-color: rgb(255 255 255 / 0.4);
      backdrop-filter: blur(5px);
      border: 1px solid silver;
      border-radius: 50%;
      line-height: 1;
      aspect-ratio: 1;
      content: "";
      top: anchor(center);
      inset-inline: anchor(start) anchor(end);
      background-size: 16px 16px;
      background-repeat: no-repeat;
      background-position: center;
      transition: background-color 0.5s ease-out;
      z-index: 1;
      @media (width < 800px) {
        display: none;
      }

      &:hover,
      &:active {
        background-color: rgb(255 255 255);
      }
    }

    &::scroll-button(inline-start) {
      translate: -50% -50%;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='1.5' stroke='currentColor' class='size-6'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M15.75 19.5 8.25 12l7.5-7.5' /%3E%3C/svg%3E%0A");
    }

    &::scroll-button(inline-end) {
      inset-block-start: anchor(center);
      inset-inline: auto anchor(end);
      translate: 50% -50%;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='1.5' stroke='currentColor' class='size-6'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='m8.25 4.5 7.5 7.5-7.5 7.5' /%3E%3C/svg%3E%0A");
    }

    &::scroll-button(block-start) {
      inset-block: anchor(top) auto;
      inset-inline: anchor(center);
      translate: -50% -50%;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='1.5' stroke='currentColor' class='size-6'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='m4.5 15.75 7.5-7.5 7.5 7.5' /%3E%3C/svg%3E%0A");
    }

    &::scroll-button(block-end) {
      top: anchor(bottom);
      left: anchor(center);
      translate: -50% -50%;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='1.5' stroke='currentColor' class='size-6'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='m19.5 8.25-7.5 7.5-7.5-7.5' /%3E%3C/svg%3E%0A");
    }
  }
}

@layer squareStyles {
  .carousel div {
    font-family: "Barrio", serif;
    font-weight: 400;
    font-style: normal;
    font-size: 40cqi;
    text-align: center;
    background: oklch(0.73 0.28 339.69);
    color: oklch(0.92 0.22 101.77);

    &:nth-child(2) {
      background: oklch(0.92 0.22 101.77);
      color: oklch(0.73 0.28 339.69);
    }

    &:nth-child(3) {
      font-family: "Kablammo", serif;
      font-optical-sizing: auto;
      font-weight: 400;
      font-style: normal;
      font-variation-settings: "MORF" 0;
      font-size: 30cqi;
      background: oklch(0.7 0.25 37.17);
      color: oklch(0.35 0.23 266.07);

      span {
        rotate: -8deg;
      }
    }

    &:nth-child(4) {
      font-family: "Kablammo", serif;
      background: oklch(0.56 0.26 259.48);
      color: oklch(0.71 0.24 41.42);
    }

    &:nth-child(5) {
      background: rebeccapurple;
      color: oklch(0.69 0.25 24.42);
    }

    &:nth-child(6) {
      color: rebeccapurple;
    }

    &:nth-child(7) {
      background: oklch(0.87 0.21 165.52);
      color: oklch(0.24 0.1 267.65);
    }

    &:nth-child(8) {
      font-family: "Kablammo", serif;
      font-size: 30cqi;
      background: oklch(0.31 0.1 332.94);
      color: oklch(0.86 0.34 142.6);
    }

    &:nth-child(9) {
      font-family: "Rubik Puddles", serif;
      font-size: 23cqi;
      background: oklch(0.32 0.11 156.6);
      color: oklch(0.7 0.33 342.92);

      span {
        rotate: -40deg;
      }
    }
  }
}

@layer base {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    background-color: #ff99f0;
    background-image: radial-gradient(
        at 76% 24%,
        hsla(299, 70%, 75%, 1) 0px,
        transparent 50%
      ),
      radial-gradient(at 2% 74%, hsla(228, 81%, 67%, 1) 0px, transparent 50%),
      radial-gradient(at 22% 67%, hsla(297, 75%, 75%, 1) 0px, transparent 50%),
      radial-gradient(at 74% 93%, hsla(28, 63%, 65%, 1) 0px, transparent 50%),
      radial-gradient(at 0% 21%, hsla(3, 96%, 67%, 1) 0px, transparent 50%),
      radial-gradient(at 89% 23%, hsla(199, 64%, 66%, 1) 0px, transparent 50%),
      radial-gradient(at 83% 29%, hsla(183, 92%, 64%, 1) 0px, transparent 50%);
  }

  .wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 100vh;
    padding: 2vmax;
    background: radial-gradient(rgb(0 0 0 / 0.8) 70%, transparent 30%),
      radial-gradient(rgb(20 20 20 / 0.6) 70%, transparent 15%);
    background-size: 4px 4px;
    background-position: 0 0, 2px 2px;
  }

  svg {
    display: block;
    width: 70cqi;
    aspect-ratio: 1;
    height: auto;
  }
}

.warning {
  background: #ffd503;
  font-family: Helvetica, Arial, sans-serif;
  position: fixed;
  top: 20px;
  left: 20px;
  padding: 20px;
  max-width: 500px;
  border-radius: 5px;
  z-index: 100;
}

@supports (scroll-marker-group: after) {
  .warning {
    display: none;
  }
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.