Format Code Now
/
Web & markupHTML Details Generator Next: HTML Email Input Generator ›

HTML Details and Summary Generator

WM-53

Write a summary line and the hidden content under it, and get native details markup that opens and closes without any script.

Runs in your browser. Nothing is uploaded.

summary: heading lines, each followed by its content (optional name: line)

HTML

How to use it

  1. Start each item with a summary: line, then write the hidden content on the lines below it.
  2. Leave a blank line between paragraphs inside an item.
  3. Optionally add a name: line to make the items an exclusive group.
  4. Tick Open the first item if one should start open, then copy the HTML.

How details and summary work

The details element is a disclosure widget: the summary child is the always-visible heading, and everything else is hidden until the user opens it. The browser supplies the arrow, the click and keyboard handling, so no script is needed. Opening adds the open attribute to details; an element that carries that attribute starts open. Scripts can listen for the toggle event, which fires when the state changes. The summary must be the first child, and the tool always writes it first.

Exclusive groups with the name attribute

A name: line gives every generated details element the same name attribute. In browsers that support it, opening one item closes the others with the same name, which gives an accordion with no script. Where it is not supported the items simply behave as independent widgets, so the content stays reachable either way. Use it for a list of questions where only one answer needs to be on screen at a time.

What the generator writes and what it leaves out

Each blank-line-separated block becomes a p. The content is escaped, so you cannot put links or other tags inside with this tool; add them to the output by hand. An empty summary or an item with no content is refused with a message naming the item. No CSS is added: the default marker is the browser's own and you can restyle it with the summary marker rules in your stylesheet.

Error messages and what to do

MessageWhat it meansFix
Add a "summary: heading" line, then the hidden content on the lines below it.The input has no summary: line at all.Start the text with summary: Your heading, then put the content on the next lines.

Questions people ask

How do I make a collapsible section in HTML?

Use details with a summary child. The summary is the visible heading; the rest is hidden until clicked. The tool builds this from your lines with no script.

How do I make a details element open by default?

Add the open attribute. Tick the Open the first item option and the first generated details element gets it. The attribute has no value; its presence alone is enough. Users can still close it by clicking the summary.

Can I make an accordion where only one item stays open?

Give the details elements the same name attribute. Browsers that support it close the others when one opens. Use a name: line in the input and the tool applies it to every item.

Is details accessible by default?

It is keyboard operable and announces its expanded or collapsed state in assistive technology, because the browser handles that for the summary. Keep the summary text meaningful, since it is the name users hear.

Can I put HTML inside the content?

The tool escapes everything you type, so tags show as text. Paste the generated structure into your page and add links or lists there by hand.

About this tool

Each summary: line starts a new details element, and the lines below it, split into paragraphs at blank lines, become its hidden content. A name: line gives every details element the same name attribute; browsers that support it keep only one of the group open at a time, and the output still works as separate widgets where it is not supported. The open option applies to the first item only. Disclosure state is handled by the browser, so no script is added and nothing is styled. Text is escaped, which means you cannot put HTML tags inside the content with this tool.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.