HTML Accordion and Tabs Generator
Type or paste your sections, choose accordion or tabs, test them with the keyboard in a live preview and copy code that works on any website.
Działa w Twojej przeglądarce. Twoje pliki nigdy nie opuszczają urządzenia. Zobacz, jak to sprawdzić
…
Jak to zrobić
- 1Choose the component
Click Accordion or Tabs at the top; the same panels are used for both.
- 2Write the panels
Edit titles and content, add, duplicate, reorder or delete panels, or import Q and A text.
- 3Set the behaviour
For accordions pick ARIA or native markup, one-at-a-time and the heading level; for tabs pick orientation and keyboard mode.
- 4Style it
Choose icons, tab style, colours, radius and spacing, and a class prefix.
- 5Test with the keyboard
In the preview, press Tab, arrows, Home, End, Enter and Space to check the behaviour.
- 6Copy the code
Copy the HTML, CSS, script and FAQPage JSON-LD, or download one HTML file.
O tym narzędziu
FAQ sections, product details, pricing notes and documentation pages all need the same two components: an accordion that shows one answer at a time and a set of tabs that switches between panels. Most snippets found online are built from divs with click handlers, so they cannot be reached with the Tab key, say nothing to screen readers, and break when two copies sit on one page. This generator writes both components the accessible way. Enter the panels in an editor where each has a title and content, duplicate, reorder and delete them, or paste a whole list of questions and answers in Q: and A: form or as title-and-paragraph blocks. Content can be plain text, which is turned into paragraphs with line breaks kept, or HTML for links, lists and bold text, with scripts and event handlers removed. The accordion comes in two versions. The ARIA version puts a button inside a heading of the level you pick, links it to its region with aria-controls and aria-labelledby, toggles aria-expanded and the hidden attribute, supports one-at-a-time or many-open behaviour, and lets the up and down arrows, Home and End move between headers. The native version uses details and summary with no script at all and the name attribute for one-at-a-time behaviour. The tabs follow the WAI-ARIA tabs pattern: a tablist with a label, roving tabindex, arrow keys that wrap around, Home and End, automatic or manual activation, and horizontal or vertical orientation. Pick chevron or plus icons and their side, underline, pill or boxed tabs, colours, radius and spacing, and you can add FAQPage structured data built from the same questions.
Accordion or tabs
Use an accordion when people scan a list of questions and open the one they care about, or when the content is long and mostly read on phones. Use tabs for a few parallel views of the same thing, such as features, specifications and reviews, where seeing the labels side by side helps. On narrow screens the tab row scrolls sideways instead of squeezing the labels.
ARIA buttons or details and summary
The details element is the lightest choice and works without JavaScript, but screen readers announce it as a disclosure rather than as part of a heading structure, and the one-at-a-time name attribute only works in recent browsers. The ARIA version puts every title in a real heading, so the page outline stays correct, and it works the same everywhere.
FAQ structured data
The FAQPage JSON-LD repeats each question and answer in a form search engines read. Since 2023 Google shows FAQ rich results mainly for well-known government and health websites, so do not expect extra space in results, but the markup is still valid and useful to other tools. Mark up only questions and answers that are visible on the page.
Limits
The generator does not animate panel height, because animating hidden content conflicts with the hidden attribute and with reduced-motion settings. Nested accordions and tabs inside tabs are not generated; build the inner one separately with a different class prefix.
Przykład z rozwiązaniem
Three delivery questions become an accordion with h3 headings, chevrons on the right and the first answer open. The HTML is 27 lines, the CSS 15 rules and the script 10 lines, and the FAQPage JSON-LD is about 1,000 characters with three Question entries. Switching the same panels to vertical tabs with manual activation gives 17 lines of HTML and a 16-line script; in the preview, the down arrow moves focus to the next tab and Enter shows its panel.
W skrócie
- Kategoria: Programowanie i dane
- Działa w przeglądarce, bez rejestracji i wysyłania.
- Wpisane informacje zostają na Twoim urządzeniu.
- Dostępne po angielsku.
- Treść ostatnio sprawdzona:
- Oficjalne źródło: W3C WAI-ARIA Authoring Practices, Accordion and Tabs patterns
Najczęstsze pytania
Is the generated code accessible?
Yes. It follows the W3C WAI-ARIA Authoring Practices for accordions and tabs: real buttons, correct roles, aria-expanded or aria-selected, labelled regions and panels, visible focus rings, and the keyboard keys users of assistive technology expect.
Can I have several accordions on one page?
Yes. Give each one its own class prefix, for example faq and specs. The prefix is used for classes and element ids, so two widgets never share an id.
Does it work without JavaScript?
The details and summary version needs no script. The ARIA accordion and the tabs need the short script included; without it, all panels except the first stay hidden, so keep the script with the HTML.
Can I paste an existing FAQ?
Yes. Paste lines starting with Q: and A:, or blocks where the first line is the title and the following lines are the content, separated by blank lines. Then replace the current panels or append to them.
Can answers contain links and lists?
Turn on Content is HTML and write normal HTML such as a links, ul lists and strong tags. Script tags, onclick-style attributes and javascript: links are removed for safety.
Where are my panels stored?
Only in this browser's local storage, so the work survives a reload. Nothing is uploaded.
