Skip to the main content

FAQ Accordion

Free Layout

An accordion of five questions on details and summary, with an animated chevron and one open at a time through the name attribute.

Checked on 3 December 2026 in Chrome 143.0.7499.169: 12 automated checks. What the checks are

Preview and code

HTML

<section class="faq" aria-labelledby="faq-title">
  <p class="faq__eyebrow">Example FAQ</p>
  <h2 id="faq-title" class="faq__title">Questions about Sample Notes</h2>
  <p class="faq__lead">An imaginary notes app, used here to show how the answers fold open. Open one and the others close.</p>
  <div class="faq__list">
    <details class="faq__item" id="faq-1" name="faq-accordion" open>
      <summary class="faq__q"><span class="faq__q-text">How do I start a new note?</span><svg class="faq__chev" viewBox="0 0 20 20" width="20" height="20" aria-hidden="true" focusable="false"><path d="M5 8l5 5 5-5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></summary>
      <div class="faq__a"><p>Press the plus button at the top of the list, or use the shortcut <kbd>N</kbd>. The cursor lands in the title so you can type straight away.</p></div>
    </details>
    <details class="faq__item" id="faq-2" name="faq-accordion">
      <summary class="faq__q"><span class="faq__q-text">Can I organise notes into groups?</span><svg class="faq__chev" viewBox="0 0 20 20" width="20" height="20" aria-hidden="true" focusable="false"><path d="M5 8l5 5 5-5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></summary>
      <div class="faq__a"><p>Yes. Give a note one or more tags, then pick a tag in the side list to see only those notes. A note with no tag stays in the main list.</p></div>
    </details>
    <details class="faq__item" id="faq-3" name="faq-accordion">
      <summary class="faq__q"><span class="faq__q-text">What happens when I delete a note?</span><svg class="faq__chev" viewBox="0 0 20 20" width="20" height="20" aria-hidden="true" focusable="false"><path d="M5 8l5 5 5-5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></summary>
      <div class="faq__a"><p>It moves to the bin, where it stays until you empty the bin. Restore it from there with one press.</p></div>
    </details>
    <details class="faq__item" id="faq-4" name="faq-accordion">
      <summary class="faq__q"><span class="faq__q-text">Can I print or export a note?</span><svg class="faq__chev" viewBox="0 0 20 20" width="20" height="20" aria-hidden="true" focusable="false"><path d="M5 8l5 5 5-5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></summary>
      <div class="faq__a"><p>Use Export on the note menu to save a plain text or HTML file, or print the page and the toolbar is left out of the paper copy.</p></div>
    </details>
    <details class="faq__item" id="faq-5" name="faq-accordion">
      <summary class="faq__q"><span class="faq__q-text">Where do I report a problem?</span><svg class="faq__chev" viewBox="0 0 20 20" width="20" height="20" aria-hidden="true" focusable="false"><path d="M5 8l5 5 5-5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></summary>
      <div class="faq__a"><p>Use the Help page and describe what you did, what you expected and what happened instead. A screenshot makes it quicker to follow.</p></div>
    </details>
  </div>
</section>

CSS

.faq {
  --faq-surface: #ffffff;
  --faq-fg: #1b2032;
  --faq-muted: #4a5266;
  --faq-line: #d3d8e6;
  --faq-accent: #4338ca;
  --faq-soft: #eceeff;
  --faq-kbd: #f3f4fb;
  --faq-ring: #4338ca;
  box-sizing: border-box;
  width: min(100%, 36rem);
  color: var(--faq-fg);
}
.faq *, .faq *::before, .faq *::after { box-sizing: border-box; }
.faq__eyebrow { margin: 0 0 0.35rem; color: var(--faq-accent); font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.faq__title { margin: 0; font-size: 1.5rem; line-height: 1.25; letter-spacing: -0.015em; }
.faq__lead { margin: 0.4rem 0 1.25rem; color: var(--faq-muted); line-height: 1.5; }
.faq__list { display: grid; gap: 0.6rem; }
.faq__item {
  background: var(--faq-surface);
  border: 1px solid var(--faq-line);
  border-radius: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.faq__item[open] { border-color: var(--faq-accent); box-shadow: 0 8px 24px -16px rgba(67, 56, 202, 0.55); }
.faq__q {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 56px;
  padding: 0.75rem 1rem 0.75rem 1.1rem;
  font-weight: 600;
  line-height: 1.35;
  cursor: pointer;
  list-style: none;
  border-radius: 13px;
}
.faq__q::-webkit-details-marker { display: none; }
.faq__q:hover { background: var(--faq-soft); }
.faq__q:focus-visible { outline: 3px solid var(--faq-ring); outline-offset: 2px; }
.faq__chev {
  flex: none;
  width: 32px;
  height: 32px;
  padding: 6px;
  color: var(--faq-accent);
  background: var(--faq-soft);
  border-radius: 50%;
  transition: transform 0.25s ease;
}
.faq__item[open] .faq__chev { transform: rotate(180deg); }
.faq__a { padding: 0 1.1rem 1.1rem; color: var(--faq-muted); line-height: 1.65; }
.faq__a p { margin: 0; }
.faq__item[open] .faq__a { animation: faq-open 0.25s ease both; }
.faq kbd {
  padding: 0.05rem 0.4rem;
  font: 600 0.8125rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--faq-fg);
  background: var(--faq-kbd);
  border: 1px solid var(--faq-line);
  border-radius: 5px;
}
@keyframes faq-open { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-color-scheme: dark) {
  .faq {
    --faq-surface: #1a1e2e;
    --faq-fg: #edf0fa;
    --faq-muted: #b9bfd3;
    --faq-line: #3a4157;
    --faq-accent: #aeb1ff;
    --faq-soft: #272c47;
    --faq-kbd: #11131f;
    --faq-ring: #c9cbff;
  }
  .faq__item[open] { box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
  .faq__item, .faq__chev { transition: none; }
  .faq__item[open] .faq__a { animation: none; }
}

Accessibility notes

Written by the author of the snippet. Each note has a test step or a markup check that reads the page.

  • Native details and summary give the expanded state and keyboard support with no script.
  • Opening one answer closes the others, grouped by the name attribute.
  • The chevron is decorative and hidden from screen readers.
Layout
Free

Site Footer

A site footer with a short brand note, four groups of links that wrap from four columns to two to one, and a bottom bar with a back-to-top link.

  • HTML
  • CSS
  • No library
  • Layout
  • Grid