A FAQ page answers common questions in small, easy-to-scan sections. Details and summary provide built-in disclosure controls for each answer.
What You Need to Know
The browser handles opening and closing a details element. Do not add JavaScript merely to imitate basic disclosure behavior; use regular headings when every answer should stay open.
Example: See It in Action
This example keeps the idea small. Copy it carefully, then follow the explanation instead of guessing what the browser will do.
This is a short HTML fragment. To try it as a webpage, put it inside the body element of a complete HTML document.
<section aria-labelledby="faq-title">
<h2 id="faq-title">Common questions</h2>
<details>
<summary>Do I need special software?</summary>
<p>Just a text editor and a browser.</p>
</details>
</section>
Let’s Understand the Example
- Section groups content around a shared topic and usually has a heading.
- An h2 starts a major section beneath the page topic.
- A p groups a paragraph of related text. Start another paragraph for a new thought.
- Aria-labelledby uses one or more existing element ids to name another element.
- Id gives one element a unique name within the page, so a link, label, or script can point to it.
You should see a readable heading and its related content. The heading level tells readers how the ideas fit together, not merely how large the letters look.
What Should You See?
The page should display “Common questions” as a heading, followed by its related content. Change the heading text and refresh the browser to see the result.
Read only the headings, from top to bottom. Do they tell a sensible story? If not, move sections or choose levels that match the content.
Try It Yourself
- Add another question with a complete answer and test it using the keyboard.
- Save your changes, open or refresh the page, and compare the result with the original example.
- Tell a friend what your change did. If you are not sure, undo it, refresh the page, and compare.
Common Beginner Mistakes
- Assuming summary works as an ordinary standalone heading outside details.
- Avoid picking tags just for their default bold, italic or spaced appearance. Use CSS for presentation.
Key Takeaways
- A FAQ page answers common questions in small, easy-to-scan sections.
- Section groups content around a shared topic and usually has a heading.
- The browser handles opening and closing a details element. Do not add JavaScript merely to imitate basic disclosure behavior; use regular headings when every answer should stay open.