FRENVersion française

Overlays & display

Carousel

Carrousel

Demo

Loading demo…

A horizontal row of content you move through one screen at a time, with arrows, dots or a swipe. It fits several images or cards into one slot, and hides everything that is off screen.

Story

Did you know

In 2013, Erik Runyon measured the carousels on the University of Notre Dame website: about 1% of visitors clicked, mostly on the first slide. A developer even built shouldiuseacarousel.com, which cycles through arguments against carousels… in a carousel.

Timeline

  1. Before the webThe word comes from the merry-go-round, and before that from equestrian parades.
  2. 2000sFlash, then jQuery sliders take over homepages.
  3. 2013Studies by Runyon and NN Group show how little they work.
  4. 2020sBack in favour as swipeable rows on mobile.

Vocabulary

Names

FR
Carrousel, diaporama, slider
EN
Carousel, slideshow, slider, image slider, hero slider

Common uses

  • Product photo galleries
  • Three-screen onboarding
  • Netflix-style content rows
  • Homepage hero banner (often best avoided)

Often paired with

The components it usually sits with, by page type, in reading order.

Code

<section aria-roledescription="carousel" aria-label="Product photos">
  <button class="prev" aria-label="Previous slide">‹</button>
  <div class="track">
    <img src="front.jpg" alt="Front view">
    <img src="side.jpg" alt="Side view">
    <img src="detail.jpg" alt="Fabric detail">
  </div>
  <button class="next" aria-label="Next slide">›</button>
</section>

<style>
.track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; }
.track > img { flex: 0 0 100%; scroll-snap-align: start; }
</style>

<script>
const track = document.querySelector('.track')
const go = (dir) => track.scrollBy({ left: dir * track.clientWidth, behavior: 'smooth' })
document.querySelector('.prev').addEventListener('click', () => go(-1))
document.querySelector('.next').addEventListener('click', () => go(1))
</script>

Good to know

  • CSS Scroll Snap does 90% of the work: native touch swipe, momentum, no library.
  • For the arrows, a scrollBy() of one track width is enough: snapping settles the position for you.
  • Add loading="lazy" to every image after the first and lock their ratio (aspect-ratio) to avoid layout shifts.
  • Chrome 135+ generates arrows and dots in pure CSS with ::scroll-button() and ::scroll-marker. Use them as a progressive enhancement.

Accessibility

Must have

  • The container gets aria-roledescription="carousel" and an aria-label. Each slide is a role="group" with aria-roledescription="slide" and a name like "2 of 5".
  • Previous and next are real <button> elements with an accessible name: a bare arrow tells a screen reader nothing.

Often forgotten

  • Auto-rotation: avoid it, or add a visible pause button (WCAG 2.2.2). Rotation must also stop on hover and whenever focus enters the carousel.
  • While auto-rotating, set the slide area to aria-live="off", then "polite" once stopped: otherwise every change gets announced.
  • Pagination dots are often silent <span>s. Make them named buttons ("Go to slide 3"), or follow the APG "tabbed carousel" pattern.

Nice to have

  • Respect prefers-reduced-motion: instant scrolling and no auto-rotation.
  • Show the position as text ("2 / 5") on top of the dots.

Who uses it