Content · Web Development · HTML

HTML HTML Component Exercise: Disclosure FAQ

HTML Component Exercise: Disclosure FAQ: Each question is a summary the visitor can expand, while the answers stay inside their details elements. Includes a practical HTML example and an explanation.

2 views Published Oct 19, 2026 Updated Oct 19, 2026 Admin

Let’s take one interactive feature apart so the markup and behavior make sense separately.

What You Need to Know


A disclosure FAQ lets visitors open questions as needed. Details and summary provide an accessible starting point without a custom click handler for each question.

Try the Example


Take a look at the example. We’ll explain the important lines right below it.

<section aria-labelledby="faq-heading">
    <h2 id="faq-heading">Frequently asked questions</h2>
    <details>
        <summary>Do I need JavaScript?</summary>
        <p>Not to create a basic HTML webpage.</p>
    </details>
    <details>
        <summary>Can I use CSS?</summary>
        <p>Yes, CSS controls the appearance.</p>
    </details>
</section>

Let’s Read the Code


  • <section>: A section groups content with a shared topic.
  • <h2>: A heading divides the page into understandable parts.
  • aria-labelledby: Aria-labelledby uses the text of another element as the accessible name.
  • id: An id uniquely identifies an element on this page.

What the example shows: Each question is a summary the visitor can expand, while the answers stay inside their details elements.

What Happens in the Browser?


When this example includes JavaScript, it supplies behavior that ordinary HTML does not automatically provide. Always think about a fallback.

Start with native behavior. Details, dialog, and popover each solve a different interface problem. Choose the simplest control that actually matches what a visitor wants to do, then test focus and dismissal as well as appearance.

Your Turn


Add a third question and test all three with Enter and Space.

Common Beginner Mistakes


  • Assuming new HTML syntax works in every browser without testing.
  • Do not put a separate button inside summary for the same expand/collapse action.

Key Takeaways


  • A disclosure FAQ lets visitors open questions as needed.
  • <section>: A section groups content with a shared topic.
  • Test the behavior you expect rather than trusting how the snippet looks in your editor.
Share this resourceSend this page to someone who may find it useful.