Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 2.6 — Built-in Interactive Elements
HTML · Example 1 of 3 Baseline 2024+

details and summary: an FAQ accordion

Same name, so opening the second closed the first. The toggle event arrives a moment later (it is queued, not fired instantly). Click the summaries yourself too.

details/summary give you an open-and-close section, dialog gives you a real popup window, and the popover attribute makes menus and tips that appear on top; all with keyboard support and accessibility built in, often with no JavaScript.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 6 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Build a two-question FAQ where only one answer can be open at a time and the first is open at the start.

02

Build a "Subscribe?" modal with Yes/No buttons that logs the choice when it closes. Open it from a button.

03

Make a button that toggles a small help popover with the text "Passwords need 12 characters".

Explain it without notes

01

What does showModal() give you that show() doesn't?

02

How does <form method="dialog"> work?

03

What is light dismiss, and which kind of popover has it?

04

Why are native details, dialog and popover better than hand-built div widgets?

details and summary: an FAQ accordion Baseline 2024+

Preview

Press Run to see the page.

Console

Nothing logged yet.

Expected console output

Start: true false
After opening the second: false true
toggle event, second is open: true