Erroneous: "List items (<li>) are not contained within <ul> or <ol> parent elements."
See original GitHub issueProvide the steps to reproduce
- Run an accessibility audit on https://app.nxtboard.com/meetings/nxtboard-sqa/
What is the current behavior?
Error:
List items (
<li>
) are not contained within<ul>
or<ol>
parent elements.
What is the expected behavior?
This error does not appear. The <li>
s in question are definitely contained inside a <ul>
element.
Environment Information
- Affected Channels: DevTools
- Lighthouse version: I don’t know. Chrome version is 76.0.3809.132 (Official Build) (64-bit).
- Node.js version: n/a
- Operating System: macOS 10.14.6
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:6 (1 by maintainers)
Top Results From Across the Web
<li> elements must be contained in a <ul> or <ol> | Axe Rules
List items may be contained in either unordered (bullet) lists or ordered ... All list items ( li ) must be contained within...
Read more >Failing accessibility audit when a ol element has a role
List items ( <li> ) are not contained within <ul> or <ol> parent elements. This error message is not explicit. Implicit role for...
Read more >List items (<li>) are not contained within <ul> or <ol> parent ...
At first glance it makes sense to me that the role=group is there on the ul element, yet such attributes and roles are...
Read more >Why should li be contained within ul or ol parent elements?
List items such as <li> must be contained within parent <ul> or <ol>. ... If list elements <li> are not contained in parent...
Read more >Accessibility rule: <ul> and <ol> must only directly contain <li ...
Lists must be correctly marked up, which means they cannot contain content components other than li elements. Lists are read aloud in a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
What happens if you put
role=presentation
on theli
element? That should essentially remove it from the accessibility tree.Yep, that’s correct. It’s also worth noting that, in Safari at least, if you change the display of a list then they throw out its semantics anyway (see the last comment in this ticket).
I think over the years it became a common practice to put navigation into ul/li elements, but that practice probably predates ARIA and has just stuck around. Since you’re redefining the semantics with ARIA it doesn’t matter much what the underlying HTML element is in this case.
@patrickhulce It looks like Axe reports the same issue. I think your hypothesis might be right. Setting their role to
"tab"
fixes the issue, but I think the anchor tags are supposed to have that role instead of the list items.I can also work around the issue by using div’s instead of list items:
Replacing the
<ul>
and<li>
elements with<div>
s fixes the issue:This doesn’t match Bootstrap 4’s suggested markup, but maybe their guide is wrong? Is there is disadvantage to using divs instead of list items?