实现说明
标记使用语义化元素 details、summary 而非通用容器,辅助技术与搜索引擎无需额外约定就能读到真实结构。
<details>/<summary> 是无需 JavaScript 的原生折叠控件。
表单通过 type="checkbox"、type="number"、type="submit" 字段收集输入,每个控件都配了 <label>,屏幕阅读器能正确播报。
常见问题
为什么用语义化元素而不是 div?
<details>、<summary> 把文档结构直接暴露给辅助技术和搜索引擎,无需 ARIA 或类名约定。
核心语句
<summary>Advanced Settings</summary>
<input type="checkbox" name="debug" />
<input type="number" name="maxconn" value="10" min="1" max="100" />
代码示例
<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>