The user wants to implement a CSS-only carousel with accessible controls, avoiding JavaScript. They probably need a complete code example, an explanation of accessibility, possibly using checkboxes or radio buttons with labels. I want to keep it concise but thorough, supplying HTML and CSS while considering ARIA attributes for screen-reader support and keyboard navigation. I plan to include focus indication and reading order while providing some brief notes alongside the code. This is a fun challenge!Implementing a progressive enhancement carousel
I want the carousel implementation to support progressive enhancement, showing all slides stacked vertically by default when CSS is off. Accessibility is key, so I’m considering using <figure> or <li> elements. For previous and next navigation, I could utilize labels tied to radio inputs, but I realize labels aren't buttons semantically. However, I can add tabindex="0" to make them focusable, so pressing Enter/Space toggles the associated radio. The semantics might not be perfect, but I think it could work well enough for screen readers.Exploring carousel alternatives with :target
One alternative is to use <a href="#slide1"> links and the :target CSS pseudo-class to show each slide. This approach is keyboard-accessible since links are focusable and allow for direct linking. However, using :target modifies the URL hash, and navigating "Next" or "Prev" just links to the slide's ID. For semantics, these links could be styled as <a role="button"> with aria-controls. I'll need to ensure that each slide is set up correctly, targeting the right elements for visibility.Utilizing the radio-group method
I'm considering using a radio-group method for the carousel, which avoids relying on URL hashes. To improve accessibility, I’ll set tabindex="0" on labels to make them focusable, and I can add screen reader annotations. However, there are concerns from experts about CSS-only carousels breaking semantics. To ensure accessibility, I’ll implement ARIA roles like role="region" with aria-roledescription="carousel", even though support might be uneven. I must keep controls focusable, ensure proper reading order, and note that auto-rotation isn’t recommended in accessible design.Designing a CSS-only accessible carousel
The user wants a CSS-only carousel with manual controls. I'm considering using an accessible radio-group method, but there are challenges like how to hide inputs while keeping them functional. Instead, I think using a layout with horizontal scrolling and scroll-snap might simplify things. Each slide would be accessible through anchor tags for navigation, like <a href="#slide2">Next</a>. This keeps it semantic while allowing normal scrolling behavior. I’ll format it to ensure keyboard navigation works well and screen readers can treat it as a scrollable region.Building an accessible carousel with scroll-snap
I need to ensure that when we anchor, it smoothly scrolls the container, not just the document. The idea is to use horizontal scrolling with scroll-behavior: smooth. I'll create the HTML structure with clear navigation links for moving between slides.
I’ll also implement scroll-snap for smooth transitions. While pagination links should be navigable for screen readers, I may need to mark them appropriately. Overall, I’ll focus on making it functional even without CSS, maintaining accessible controls and clear semantics. Let's put together a code snippet! Below is a complete, CSS‑only carousel that:
Uses only HTML + CSS (no JavaScript).
Is keyboard‑accessible (Tab, Enter/Space, and arrow keys to scroll).
Degrades gracefully when CSS is disabled (just a vertical list of content).
Uses regular links and a scrollable region instead of “magic” radios, which is much more robust for assistive tech.
The trick is to use horizontal scrolling + scroll-snap and regular anchor links as “Next” / “Previous” controls.
HTML
html
<section class="carousel" aria-label="Featured images" aria-roledescription="carousel">
<h2 class="carousel__title">Featured images</h2>
<!-- Skip link for keyboard users -->
<a class="carousel__skip-link" href="#after-carousel">Skip carousel</a>
<!-- Scrollable viewport -->
<div class="carousel__viewport" tabindex="0">
<!-- Slide 1 -->
<figure class="carousel__slide" id="slide-1" aria-label="Slide 1 of 3">
<img src="image1.jpg" alt="A calm lake surrounded by mountains">
<figcaption>Peaceful mountain lake at sunrise.</figcaption>
<nav class="carousel__controls" aria-label="Slide 1 controls">
<a href="#slide-3" class="carousel__control carousel__control--prev">
Previous slide
</a>
<a href="#slide-2" class="carousel__control carousel__control--next">
Next slide
</a>
</nav>
</figure>
<!-- Slide 2 -->
<figure class="carousel__slide" id="slide-2" aria-label="Slide 2 of 3">
<img src="image2.jpg" alt="Forest trail with sunlight streaming through trees">
<figcaption>Forest trail with morning light.</figcaption>
<nav class="carousel__controls" aria-label="Slide 2 controls">
<a href="#slide-1" class="carousel__control carousel__control--prev">
Previous slide
</a>
<a href="#slide-3" class="carousel__control carousel__control--next">
Next slide
</a>
</nav>
</figure>
<!-- Slide 3 -->
<figure class="carousel__slide" id="slide-3" aria-label="Slide 3 of 3">
<img src="image3.jpg" alt="City skyline at dusk with lights reflected on the river">
<figcaption>City skyline at dusk.</figcaption>
<nav class="carousel__controls" aria-label="Slide 3 controls">
<a href="#slide-2" class="carousel__control carousel__control--prev">
Previous slide
</a>
<a href="#slide-1" class="carousel__control carousel__control--next">
Next slide
</a>
</nav>
</figure>
</div>
<!-- Optional pagination dots -->
<nav class="carousel__pagination" aria-label="Choose slide">
<a href="#slide-1">1</a>
<a href="#slide-2">2</a>
<a href="#slide-3">3</a>
</nav>
</section>
<p id="after-carousel">
Content after the carousel…
</p>