First slide

Second slide

Third slide

Seconds

Help Us Improve

—

(—)

CSS carousel generator

Build a carousel and copy the HTML and CSS. Set slides, autoplay, arrows, and dots — free, no sign-in.

Tips for carousels

Keep the row short and readable.
  • 01

    Stay under five slides

    A long autoplay row hides content. Put the important slide first.

  • 02

    Give every slide a title

    The heading is what remains if an image is slow or missing.

  • 03

    Pause is not in this snippet

    The copied autoplay keeps running. Add a pause control if the carousel sits next to text someone needs to read.

Technical details

What the snippet contains.
Scroll snap
The track sets scroll-snap-type: x mandatory. Each slide sets scroll-snap-align: start and flex-basis: 100%.
Autoplay
A data-autoplay attribute stores the delay in milliseconds. The script calls scrollTo on that interval.
Images
Preview images stay in this browser session. The snippet points at slide-1.jpg and the following file names.
Limits
One to eight slides. Autoplay delay is 2 to 10 seconds.

Sources & References

The CSS that holds each slide in place.
  • “The scroll-snap-type CSS property is set on a scroll container, opting it into scroll snapping by setting the direction and strictness of snap point enforcement within the snap port.”
    — MDN Web Docs — scroll-snap-type

    scroll-snap-type: The copied track uses scroll-snap-type: x mandatory so each slide fills the frame. developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/scroll-snap-type

  • “The properties in the CSS scroll snap module enable you to define how scrolling snaps to specific points as a user scrolls through a document.”
    — MDN Web Docs — Basic concepts of scroll snap

    Scroll snap basics: Arrows and autoplay scroll the same container. Snap alignment decides where a slide stops. developer.mozilla.org/en-US/docs/Web/CSS/Guides/Scroll_snap/Basic_concepts

Frequently Asked Questions

Quick answers about this tool—open a question to read more.