← All elements

Numbered Step Accordion

by @admin · 0 views

<div class="nsa"><details name="nsa" open><summary>Pick a plan</summary><p>Start free and upgrade whenever you like.</p></details><details name="nsa"><summary>Add your site</summary><p>Paste the address and confirm you own it.</p></details><details name="nsa"><summary>Go live</summary><p>Publish once the checks turn green.</p></details></div>

About this accordion

A how-to accordion with automatic step numbers from a CSS counter, where opening one step closes the others.

How it works

Each step is a native details element, and giving them the same name attribute makes the browser close the others when one opens. A CSS counter is reset on the wrapper and incremented on every step, and the summary prints it in a round marker before the title. The open step fills its marker with colour.

Ways to customise it

  • Change #4338ca to recolour the open marker.
  • Add more details elements and the numbers continue on their own.
  • Remove the name attribute to let several steps stay open.

Good to know

Details and summary work with the keyboard and screen readers without extra code. The name attribute for exclusive accordions is supported in current browsers, and older ones simply allow more than one open panel.

Open an example, copy the HTML and the CSS, and paste them into your page. There is nothing to install and no JavaScript to load.

More in Accordion

View all →