CSS Carousel Generator
- No JavaScript: ::scroll-button() and ::scroll-marker
- Optional script fallback for other browsers
- Arrows, dots and peek presets
- Browser support beside the code
Controls
Browser support
Support data last reviewed .
What ::scroll-button() and ::scroll-marker do
A CSS carousel is a scroll container with scroll snap, plus two new pseudo-elements. ::scroll-button() generates real previous and next buttons, and ::scroll-marker generates one dot per slide inside a ::scroll-marker-group. The browser does the scrolling, disables the buttons at either end, highlights the current dot and handles keyboard focus, so there is no JavaScript to write.
Syntax
scroll-snap-type: x mandatory; scroll-marker-group: after; ::scroll-button(right) { content: "›" / "Next slide"; }
| Part | What it controls |
|---|---|
| scroll-snap-type | Goes on the container. x mandatory makes it settle on a slide every time scrolling stops. This part works in every current browser. |
| ::scroll-button(left | right) | Generates a focusable button that scrolls the container in that direction. It is disabled automatically at the start and the end. |
| content: "›" / "Next slide" | The visible arrow, then the alternative text after the slash, which is what screen readers announce. |
| scroll-marker-group | after or before. Creates the container the markers are placed in, after or before the carousel. |
| ::scroll-marker | Generated on each slide. Clicking a marker scrolls to its slide. |
| :target-current | Matches the marker of the slide currently in view, so you can highlight it. |
| anchor-name / position-anchor | Used here to pin the buttons over the carousel edges with anchor positioning. |
Notes from practice
Safari and Firefox get a fallback
Without the new pseudo-elements the CSS still gives a working, swipeable scroll-snap carousel. For matching arrows and dots there, set Code panel to Fallback script and add the small script it gives you. It only runs in browsers without native support.
Markers behave like tabs
The browser exposes the marker group to assistive technology as a group of tabs and lets people move between markers with the arrow keys, which most hand-built dot navigation never manages.
Autoplay and loops still need JavaScript
CSS cannot advance slides on a timer or wrap from the last slide back to the first. Add a small script for those if you need them, and keep the CSS controls for everything else.
CSS Carousel Generator FAQ
How do I make a carousel without JavaScript?
Use a flex container with overflow-x: auto and scroll-snap-type: x mandatory, set scroll-snap-align on each slide, then add ::scroll-button() for the arrows and ::scroll-marker for the dots. This generator writes all of it.
Which browsers support ::scroll-button() and ::scroll-marker?
Chrome and Edge 135 and later. At the time of writing Firefox and Safari do not support them. Scroll snap works everywhere, so those browsers still get a swipeable carousel, and the optional fallback script adds the arrows and dots for them.
Are CSS carousel buttons accessible?
Yes. They are real focusable buttons whose accessible name is the text after the slash in content, and the browser disables them when there is nothing left to scroll. The markers are grouped and can be reached with the keyboard.
Can a CSS carousel show several slides at once?
Yes. Set each slide's flex-basis to a fraction of the container width minus the gaps. The Slides per view control does the maths, and Show part of the next slide leaves a peek of the following slide as a hint to scroll.
What markup does the CSS carousel need?
Any scroll container whose direct children are the slides, such as a ul with one li per slide. The generated CSS targets the container and its children with > *, so the slides need no class names.
Related generators
- Scroll Snap — Make carousels and galleries lock to each slide. Swipe or scroll the preview to feel it.
- Flexbox — Direction, wrapping, alignment and gap, plus per-item grow, align-self and order.
- Scroll-driven Animation — Link an animation to scroll position with animation-timeline. Scroll the preview to see it run.
- Tooltip & Popover — Tether a tooltip or popover to its trigger with CSS anchor positioning. It flips when it runs out of room, with no JavaScript library.
More in Layout
Part of CSSGen.dev — 34 free visual CSS generators with browser support built in.