list

Term side of the Card.
Topic: Structural Elements
Unit title: list
Categories: Role
Explanation side of the Card

Explanation: The role used to represent a collection of items, typically in a sequential or unordered format. It helps users understand that the items within the list are related and should be read or navigated as a group.

Example

Wronghtml
<ul style="list-style: none">
  <div><a href="/a">A</a></div>
  <div><a href="/b">B</a></div>
</ul>
Righthtml
<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> when list-style: none is set.
  • A <ul> contains only <li> elements, plus <script> or <template>.

Interview questions

Is 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.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy