The <details> element provides built-in expand/collapse behavior paired with a <summary>. It is keyboard accessible and doesn’t need JavaScript for basic usage.
- Click or press Enter/Space on the summary to toggle.
- Works across modern browsers.
- You can style it with CSS and enhance behavior if needed.
Learn more on MDN.