Skip to main content
Beta: Front-End Checklist is currently in beta. Some issues are still being fixed. Thanks for your patience.

Use correct list structure

Lists (ul, ol) should only contain list item elements (li) to ensure they are correctly interpreted by assistive technology.

Utilities
Quick take
Typical fix time 10 min
  • 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
Why it matters: 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.

Rule Details

HTML list elements such as <ul> (opens in new tab) and <ol> have a specific requirement: their only direct children must be <li> elements (or <script> and <template> elements). The HTML standard (opens in new tab) makes that structure explicit, so placing other tags like <div> directly inside a list breaks the semantics.

Code Example

<!-- 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.

Use with AI

Copy these prompts to use with your AI assistant, or install the MCP server to use directly from Claude, Cursor, or Windsurf.

Check

Verify implementation

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

Fix

Auto-fix issues

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

Explain

Learn more

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

Review

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.

Sources

References used to support the guidance in this rule.

Further Reading

Tools and supplementary material for exploring the topic in more depth.

axe DevTools
deque.comTool

Rules that often go hand-in-hand with this one.

Place list items within list containers

List item elements (li) must always be direct children of a list container (ul, ol, or menu) to maintain valid HTML structure and correct screen reader announcements.

Accessibility
Use correct definition list structure

Definition lists (&lt;dl&gt;) must only contain valid &lt;dt&gt; and &lt;dd&gt; elements.

Accessibility
Wrap definition items in a definition list

Description terms (&lt;dt&gt;) and details (&lt;dd&gt;) must be contained within a &lt;dl&gt; element.

Accessibility
Use semantic list elements

Groups of related items use ul, ol, or dl elements so screen readers announce list context and item count.

Accessibility

Was this rule helpful?

Your feedback helps improve rule quality. This stays internal for now.

Loading feedback...
0 / 385