How to Make Accessible Accordions and Tabs in Plain HTML
When to use an accordion or tabs, the ARIA patterns that make them keyboard friendly, and how to generate the code with FAQ structured data.

Accordions and tabs both hide content until it is asked for. That saves space and keeps long pages scannable, which is why they appear on almost every FAQ, product page and documentation site. They are also among the components most often built in an inaccessible way: clickable divs that keyboards cannot reach, panels that screen readers do not announce, and scripts that break when two copies sit on one page.
Accordion or tabs?
Use an accordion for a list of independent items where readers pick one or two, such as frequently asked questions, or when content is long and mostly read on phones. The titles stack vertically, so long questions fit.
Use tabs for a small number of parallel views of the same subject, such as Overview, Specifications and Reviews, where seeing the labels side by side helps people understand what is available. Keep tab labels short; on narrow screens the tab row scrolls sideways.
How the accessible versions work
An accessible accordion puts each title in a real heading and, inside it, a button. The button carries aria-expanded to say whether its panel is open and aria-controls to point to the panel, and the panel is a labelled region that is hidden when closed. Arrow keys can move between the buttons. Because every title is a heading, people who navigate by headings still find each question.
There is also a no-script alternative: the HTML details and summary elements. The browser handles opening and closing, and the name attribute makes a group behave one-at-a-time in recent browsers. It is the lightest option, though the titles are not headings.
Accessible tabs follow the WAI-ARIA tabs pattern. A container with the tablist role holds buttons with the tab role. Only the selected tab is in the Tab key order; the arrow keys move between tabs, Home and End jump to the first and last, and the matching panel with the tabpanel role is shown. In automatic mode, moving with the arrows also switches the panel. In manual mode, the arrows only move focus and Enter or Space selects, which is better when panels are slow to render.
Building one
In the HTML Accordion and Tabs Generator, choose Accordion or Tabs at the top; the same panels feed both. Edit titles and content directly, duplicate, reorder or delete panels, or paste an existing FAQ. Two paste formats are understood: lines starting with Q: and A:, and blocks where the first line is the title and the following lines are the answer, separated by blank lines.
Content can be plain text, which becomes paragraphs, or HTML for links, lists and emphasis. Scripts, event handler attributes and javascript: links are removed from HTML content, so pasted markup cannot run code.
Then set the behaviour. For accordions choose ARIA buttons or details and summary, one-at-a-time or several open, the first panel open or closed, and the heading level that fits your page outline. For tabs choose horizontal or vertical layout and automatic or manual activation. Styling covers chevron or plus icons and their side, underline, pill or boxed tabs, colours, radius and spacing.
Test in the preview with the keyboard before copying: Tab to the component, use the arrows, Home and End, and open and close panels with Enter and Space.
FAQ structured data
The generator can also write FAQPage JSON-LD from the same questions and answers. Since 2023 Google shows FAQ rich results mainly for well-known government and health sites, so most pages will not get extra space in search results. The markup remains valid and is read by other search engines and AI tools. Only mark up questions that are visible on the page.
Using more than one on a page
Each widget uses a class prefix that also forms its element ids. Give every accordion or tab set on the same page its own prefix, such as faq and specs, and they will never interfere with each other.



