thedaviddias/Front-End-Checklist / skills/list-structure
list-structure
VerifiedUse 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.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 1.7 KB |
| references/rule.md | markdown | 2.8 KB |
references/rule.md
View on GitHub# Use correct list structure
> Lists (ul, ol) should only contain list item elements (li) to ensure they are correctly interpreted by assistive technology.
**Priority:** medium · **Difficulty:** intermediate · **Time:** 10 min
---
HTML list elements such as [`<ul>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/ul) and `<ol>` have a specific requirement: their only direct children must be `<li>` elements (or `<script>` and `<template>` elements). The [HTML standard](https://html.spec.whatwg.org/multipage/grouping-content.html#the-ul-element) makes that structure explicit, so placing other tags like `<div>` directly inside a list breaks the semantics.
## Code Example
```html
<!-- Incorrect: Direct child is a div -->
<ul>
<div>
<li>Item 1</li>
<li>Item 2</li>
</div>
</ul>
<!-- Correct: All children are li elements -->
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>
<!-- Nested lists must be inside an li -->
<ul>
<li>Sub-item 1</li>
</ul>
</li>
</ul>
```
## Why It Matters
- **Assistive Technology Interpretation**: Screen readers announce "List of 3 items" when entering a list. Incorrect structure can cause the list to be miscounted or ignored entirely.
- **Markup Validation**: Breaking the parent-child relationship of lists makes the HTML invalid, which can lead to unpredictable rendering issues.
- **Consistency**: Users expect standard list behavior (like bullet points and numbering) which is best achieved through standard markup.
- **Search Engine Parsing**: Search engines use the structure of your lists to understand relationships between pieces of content.
## Exceptions
- Simple data tables can sometimes fail more from missing header relationships than from missing enhancements such as captions or mobile wrappers, so prioritize the strongest semantic issue.
- Do not convert layout structures into data-table markup just to satisfy a rule; the correct fix may be to remove table semantics entirely.
- When several table-accessibility issues overlap, resolve the header-cell relationship first because downstream announcements depend on it.
## Standards
- Align the implementation with W3C WAI: WCAG Overview and verify the rendered experience, not only the source code.
- Align the implementation with MDN: Accessibility and verify the rendered experience, not only the source code.
## Verification
### Automated Checks
- Inspect the browser accessibility tree or accessibility pane for the relevant element, role, or accessible name.
- Run an automated accessibility checker such as axe or Lighthouse where applicable.
### Manual Checks
- Test the affected UI with keyboard-only navigation and confirm the rule holds in the rendered experience.
- Re-test one representative user flow with a screen reader if this rule affects a key interaction.Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |