跳到正文
Skillpedia
网站与界面(前端)75k · #2923

list-structure

它能做什么

这项技能检查 HTML 列表是否只把列表项作为直接子元素。适用于希望列表能与辅助技术良好配合的网页制作者。

适用场景

  • ✓当你请智能体检查页面中列表的 HTML 标记的时候。
  • ✓当列表在屏幕上看起来正常,但你怀疑其代码结构无效的时候。
  • ✓当模板或组件输出列表,而你想确认它们符合正确结构的时候。

技能链接

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/list-structure/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/list-structure/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请帮我检查网站上的列表结构,看看屏幕阅读器能否正确读取。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会检查每个 ul 和 ol 元素,查找不是 li 元素的直接子元素。然后它会移动或包裹这些元素,使列表结构有效。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Use correct list structure

Screen readers rely on a specific parent-child relationship for lists to correctly announce the number of items and the user's current position within the list.

Quick Reference

  • Unordered (<ul>) and ordered (<ol>) lists must only contain <li> elements
  • Do not put other elements like <div> or <p> directly inside a list
  • Ensure nested lists are also properly contained within an <li> element

Check

Check the structure of all lists to ensure only <li> elements are direct children of <ul> or <ol>.

Fix

Remove or move any non-li elements from within <ul> and <ol> tags.

Explain

Explain why assistive technology needs a consistent list structure to provide accurate navigation information.

Code Review

Review the rendered markup and interactive states that affect Use correct list structure. Flag exact elements, roles, labels, focus behavior, or keyboard interactions that violate the rule, and note how to verify the fix with browser accessibility tooling or assistive tech.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/accessibility/list-structure

常见问题

列表中直接包含 div 有什么问题?

屏幕阅读器依赖清晰的父子关系,多余的元素可能会干扰项目数量和位置的判断。

列表可以嵌套吗?

可以,但嵌套的列表必须放在列表项元素之内。

这会改变列表的外观吗?

可能会。如果样式依赖于错误的结构,修复后应检查布局。

详情

作者的原始描述

Use when reviewing rendered HTML, interactive components, or design-system patterns related to Use correct list structure. Check native semantics first, then inspect keyboard behavior, focus flow, accessible names, and screen-reader output where relevant.

repo: thedaviddias/Front-End-Checklist

热度

GitHub 星标
75k
排名
#2923
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能