Back to Snippets

Pure CSS Carousel with Scroll Buttons and Markers

Five slides sit in a row. Swipe or scroll to move between them, click the arrows at either side, or click a dot underneath, and every slide snaps into place.

The track is a plain scroll container with scroll-snap-type on the inline axis and scroll-snap-align on each slide, which is what makes swiping land cleanly. The arrows are the ::scroll-button pseudo-elements, real buttons the browser renders that scroll the container by most of its visible width and disable themselves at either end. The dots come from scroll-marker-group on the container and ::scroll-marker on each slide, with :target-current styling the one for the slide in view.

Scroll snap works everywhere. ::scroll-button and ::scroll-marker landed in Chrome and Edge in 2025, so in other browsers the carousel is a swipeable snap track without the arrows and dots.

0
#css
#html
#carousel
#slider
#scroll snap
#gallery
#ui
#animation