How to fix “<ul> and <ol> must only directly contain <li>, <script> or <template> elements”
By Justin Zagar · Updated
A list on the page has something other than li items directly inside it, or an li sits outside any list. Put each item in an li, and make sure every li has a ul or ol around it.
- axe rule
list(this page also coverslistitem)- WCAG
- 1.3.1 Info and Relationships (Level A)
- Lighthouse
- Google Lighthouse and PageSpeed Insights report it as “Lists do not contain only <li> elements and script supporting elements (<script> and <template>).”
What it means
When a list is built right, a screen reader says "list, 5 items" and lets people jump past it. Deque notes that when other elements sit directly inside the list, screen readers can't tell the listener they're in a list at all.
This page covers axe's listitem rule too, which is the same problem from the other side: an li with no ul or ol around it.
It usually comes from menus or page builder widgets that wrap items in an extra div.
Who it affects
People who use a screen reader.
How to find it
- Run the free checker. The code it shows points to the list, often a menu or a feature list.
How to fix it
- Move any div, span or heading that sits directly inside the ul or ol into an li, or out of the list.
- Wrap loose li items in a ul.
- If a widget writes the markup, check its settings or theme templates, since you can't fix it in the page content.
A div between the list and its items
<ul>
<div class="row">
<li>Drain cleaning</li>
<li>Water heaters</li>
</div>
</ul><ul class="row">
<li>Drain cleaning</li>
<li>Water heaters</li>
</ul>What a scanner can and can’t tell you
Fixing this clears one automated check. It doesn’t mean the page is accessible, and it doesn’t settle any legal question. Automated tests catch only part of the problems. W3C puts it plainly: evaluation tools “can not determine accessibility, they can only assist in doing so.” The rest takes a person working through the site with a keyboard and a screen reader.
Source: W3C WAI, Selecting Web Accessibility Evaluation Tools. Not legal advice.
Sources
All checked November 8, 2026. The rule wording is axe-core 4.14.0’s own.
Related fixes
- Documents must have <title> element to aid in navigation
Page has no title
- Required ARIA attributes must be provided
ARIA roles missing required attributes
Check a page for free
Scan any page of your site against WCAG 2.1 AA in about 30 seconds. You get the problems automated testing finds, in plain words, with a link to a fix guide for the common ones.
Rather have someone fix it for you? Tell me about your site.