Details Summary Disclosure Widget
Create a native disclosure widget using the details and summary elements with custom styling and open event handling.
Code
<details>
<summary>Advanced Settings</summary>
<form>
<label>
<input type="checkbox" name="debug" />
Enable debug mode
</label>
<label>
Max connections:
<input type="number" name="maxconn" value="10" min="1" max="100" />
</label>
<button type="submit">Save</button>
</form>
</details>How the snippet works
The markup uses the semantic elements details and summary instead of generic containers, giving assistive technology and search engines real structure without extra wiring.
<details>/<summary> provide a native disclosure widget that works without JavaScript.
The form collects input via type="checkbox", type="number", type="submit" fields, each tied to a <label> so every control announces what it is.
Statements that matter
<summary>Advanced Settings</summary>
<input type="checkbox" name="debug" />
<input type="number" name="maxconn" value="10" min="1" max="100" />
Interactive Tools for This Topic
JSON to Zod Schema ConverterInfer typed Zod z.object schemas from JSON payloads locally, supporting nested objects, merged array shapes, enums, nullable fields, and JSDoc comments.JSON Schema ValidatorValidate JSON data against a JSON Schema definition and get detailed error reports. Supports type checking, required fields, and common constraint validation.JSONL / NDJSON InspectorValidate NDJSON and JSON Lines line-by-line, pinpoint syntax errors by line number, analyze key frequencies and types, and export a pretty JSON array.Credit Card Brand DetectorIdentify the card network from a number's prefix and length, validate the Luhn checksum, and show a masked form and the issuer identification number.
FAQ
- Why semantic elements instead of divs?
- `<details>`, `<summary>` expose document structure to assistive technology and search engines without ARIA or class-name conventions.
Report a problem with this exampleOpens a pre-filled issue on GitHub.