Fixing Lighthouse “Lists do not contain only li elements” in HTML Lists
Lighthouse's "Lists do not contain only <li> elements" warning goes away when you move any non-<li> element that sits directly inside a <ul> or <ol> either into a <li> or out of the list. This accessibility warning appears when you place an <a>, a heading, or a <div> directly inside a list, which is common in navigation menus, news lists, and numbered steps. With the Japanese UI, Lighthouse shows this message in Japanese. It means: "The list contains elements other than <li> and script-supporting elements (<script> and <template>)."
On the test page, I put the three common patterns on one page, as they were. The accessibility score was 83. After fixing all three, the score was 100.
The test environment was Ubuntu 24.04, Node.js 22, and Lighthouse 13.6.0 (the npm package; it uses axe-core 4.14.0 internally). I pointed the environment variable CHROME_PATH at Chrome for Testing 153, which is bundled with Playwright 1.63.0. I ran Lighthouse from the command line with the default mobile settings and checked only the accessibility category. The test page was served from a server running in the test environment (localhost:8080). I did not test the Lighthouse panel in Chrome DevTools, PageSpeed Insights, <dl> or <menu> lists, or reading with an actual screen reader.
The page that triggered the warning, and the Lighthouse output
The warning appeared on a page with three lists. The first is a menu where each <li> is wrapped in an <a> link. The second is a news list with an <h2> heading inside the <ul>. The third is a list of steps where each <li> is wrapped in a <div> for styling.
<ul class="menu">
<a href="/tama"><li>たま</li></a>
<a href="/mike"><li>みけ</li></a>
</ul>
<ul class="news">
<h2>今週のお知らせ</h2>
<li>写真を3枚足しました</li>
<li>名前の一覧を直しました</li>
</ul>
<ol class="steps">
<div class="step"><li>ごはんを量る</li></div>
<div class="step"><li>水を替える</li></div>
</ol>
I ran Lighthouse on this page. From the JSON result, I used a small script (summarize.mjs) to extract this warning (audit ID list) and the listitem result, which I cover later.
$ npx lighthouse http://localhost:8080/before.html --only-categories=accessibility --output=json --output=html --output-path=./out/before --chrome-flags="--headless=new --no-sandbox" --quiet
$ node summarize.mjs out/before.report.json
lighthouseVersion: 13.6.0 formFactor: mobile locale: en-US
requestedUrl: http://localhost:8080/before.html
accessibility score: 83
list: score=0 scoreDisplayMode=binary title="Lists do not contain only `<li>` elements and script supporting elements (`<script>` and `<template>`)."
<ul class="menu"> | Fix all of the following: List element has direct children that are not allowed: a
<ul class="news"> | Fix all of the following: List element has direct children that are not allowed: h2
<ol class="steps"> | Fix all of the following: List element has direct children that are not allowed: div
listitem: score=0 scoreDisplayMode=binary title="List items (`<li>`) are not contained within `<ul>`, `<ol>` or `<menu>` parent elements."
(In practice, I ran this from a small shell script that set CHROME_PATH. I omitted the four failing <li> lines that follow the listitem line, and the two lines that print weights.)
For each flagged list, the message "List element has direct children that are not allowed:" is followed by the names of the elements that should not be directly inside the list. Even with --locale=ja, this explanatory text stayed in English.
In the HTML report, the problematic child elements (<a href="/tama">, <h2>, and <div class="step">) are listed one by one under each flagged list. This shows you exactly where to make the fix.

Fixing each of the three patterns
The fix depends on whether the offending child is part of an item or a heading for the whole list.
<ul class="menu">
<li><a href="/tama">たま</a></li>
<li><a href="/mike">みけ</a></li>
</ul>
<h2>今週のお知らせ</h2>
<ul class="news">
<li>写真を3枚足しました</li>
<li>名前の一覧を直しました</li>
</ul>
<ol class="steps">
<li class="step">ごはんを量る</li>
<li class="step">水を替える</li>
</ol>
A link is part of an item's content, so I moved the <a> inside the <li>. A heading applies to the whole list, so I moved it outside the list, just before it. The <div> was only there for styling, so I moved its class to the <li> and removed the <div>. Running Lighthouse on the fixed page gave these results (I show only the relevant lines):
accessibility score: 100
list: score=1 scoreDisplayMode=binary title="Lists contain only `<li>` elements and script supporting elements (`<script>` and `<template>`)."
listitem: score=1 scoreDisplayMode=binary title="List items (`<li>`) are contained within `<ul>`, `<ol>` or `<menu>` parent elements"
The score went from 83 to 100. Both audits have a weight of 7. Before the fix, both failed, which lowered the score.
The MDN reference for the ul element also states that a <ul> may contain zero or more <li>, <script>, and <template> elements. This Lighthouse audit checks that same HTML rule.
How the structure exposed to browsers changes before and after
The Lighthouse description says that screen readers announce lists in a special way, so a correct structure helps them. I used Playwright's ariaSnapshot() to output the accessibility tree that browsers pass to screen readers and other assistive technology, and compared the two versions. Before the fix, the menu looked like this:
- list:
- link "たま":
- /url: /tama
- listitem: たま
- link "みけ":
- /url: /mike
- listitem: みけ
A link sits directly under the list, and each listitem is inside its link. In the news list, the heading sat inside the list alongside the listitem elements. After the fix, the order was: list, then listitem, then link inside the listitem:
- list:
- listitem:
- link "たま":
- /url: /tama
- listitem:
- link "みけ":
- /url: /mike
For the steps list wrapped in <div> elements, the output was the same before and after the fix, because ariaSnapshot() output does not include <div> elements. Even though the difference does not show up in this output, Lighthouse checks the HTML parent-child relationships and flags the problem.
The listitem warning goes away with the same fix
Before the fix, the other audit, listitem ("List items (<li>) are not contained within <ul>, <ol> or <menu> parent elements."), also failed. This warning is reported from the <li> side. Four <li> elements were wrapped in <a> or <div>, so their parent was not a <ul> or <ol>.
<li> | Fix any of the following: List item does not have a <ul> or <ol> parent element. Ensure the <li> is a direct child of a <ul> or <ol>, or that the parent has role="list".
When I removed the elements wrapping the <li>, both list and listitem passed at the same time. The page I fixed in the previous section is that case.
Where the warning does and does not appear
I tested each of the other patterns on its own page.
| Contents of the list | list result |
Score |
|---|---|---|
Besides <li>, a <script>, <template>, a comment, a hidden
<div>, a <span> with aria-hidden="true", or a <div> with role="listitem" |
Pass | 100 |
Plain text (みけ) after an <li>, not wrapped in a tag |
Fail (#text) |
90 |
A nested <ul> placed directly after an <li> |
Fail (ul) |
90 |
An <li> wrapped in a <div> with display: contents |
Fail (div) |
79 |
An <li> wrapped in a <div> with role="none" |
Fail ([role=none]) |
92 |
As the audit title says, <script> and <template> are allowed inside the list. Elements that are not shown on screen or read aloud (those with hidden or aria-hidden="true") were also not counted. A role="listitem" on an element that is not an <li> also passed.
On the other hand, removing a <div> box with display: contents in CSS does not change the HTML parent-child relationship, so the warning remains. A <div> with role="none" made listitem pass, but list still failed.
For nested lists, the test passed when the inner <ul> was placed inside the parent <li>. The MDN reference also says that when you nest lists, you put the inner list inside the parent list's <li>, not directly inside the <ul> or <ol>.
<ul>
<li>ごはん
<ul>
<li>朝</li>
<li>夜</li>
</ul>
</li>
</ul>
If you add a role attribute such as role="list" to a <ul>, the list audit no longer checks that list. On a page where a <ul role="list"> contained <li> elements wrapped in <div>, list was reported as not applicable (it does not count toward the score), and only listitem failed. Removing the list warning does not mean the structure is fixed.
This behavior comes from no-role-matches (a condition that limits the check to elements without a role attribute) in the axe-core 4.14.0 list rule. Lighthouse 13.6.0's source code for this audit does not make its own judgment. It relies on the axe-core results.





