list
Example
<ul style="list-style: none">
<div><a href="/a">A</a></div>
<div><a href="/b">B</a></div>
</ul><ul role="list" style="list-style: none">
<li><a href="/a">A</a></li>
<li><a href="/b">B</a></li>
</ul><li> children keep the list valid, and role="list" restores semantics some browsers drop with list-style: none.
Common mistakes
- Putting
<div>s directly in a<ul>. - Navigation links as bare
<a>tags with no list, so the link count is not announced.
Key points
- Lists use
<ul>or<ol>with<li>children, not<div role="list">. - A styled list that must keep its semantics has
role="list"on the<ul>whenlist-style: noneis set. - A
<ul>contains only<li>elements, plus<script>or<template>.
Interview questions
Is role="list" on <ul> redundant?
role="list" on <ul> redundant?Usually yes, but it is the accepted fix when a browser removes list semantics after list-style: none.
Why use a list for navigation links?
Screen readers announce 'list, 5 items', so users know how many links there are and can skip the list.