Details and Summary Disclosure
Uses native details and summary elements to create accessible expandable content sections without JavaScript, with custom styling.
Code
<details>
<summary>Click to expand</summary>
<p>This content is hidden by default and shown when the summary is clicked.</p>
</details>
<details open>
<summary>FAQ: What is HTML?</summary>
<p>HTML (HyperText Markup Language) is the standard markup language for web pages.</p>
</details>
<details>
<summary>Settings</summary>
<form>
<label>
<input type="checkbox" name="notifications" checked>
Enable notifications
</label>
<label>
<input type="checkbox" name="auto-save">
Auto-save changes
</label>
<button type="submit">Save Settings</button>
</form>
</details>
<details>
<summary>Code Example</summary>
<pre><code>function greet(name) {
return `Hello, ${name}!`;
}</code></pre>
</details>
<style>
summary {
cursor: pointer;
padding: 0.5rem;
font-weight: bold;
list-style: none;
}
summary::-webkit-details-marker {
display: none;
}
details[open] > summary {
border-bottom: 1px solid #ccc;
}
</style>What the code does
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="submit" fields, each tied to a <label> so every control announces what it is.
Statements that matter
<summary>Click to expand</summary>
<p>This content is hidden by default and shown when the summary is clicked.</p>
<details open>
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.