Fix guide · Broken list markup

How to fix “<ul> and <ol> must only directly contain <li>, <script> or <template> elements”

By · 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 covers listitem)
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

  1. Run the free checker. The code it shows points to the list, often a menu or a feature list.

How to fix it

  1. Move any div, span or heading that sits directly inside the ul or ol into an li, or out of the list.
  2. Wrap loose li items in a ul.
  3. 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

Before · fails
<ul>
  <div class="row">
    <li>Drain cleaning</li>
    <li>Water heaters</li>
  </div>
</ul>
After · fixed
<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

Every fix guide →

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.

Run the free checkno sign up · one page at a time

Rather have someone fix it for you? Tell me about your site.