HTML Unordered Lists: Items and Nested Lists
Group related items
Use ul for a collection whose sequence is not essential to its meaning. Each ordinary item is an li child. Browsers commonly display a bullet before each item; the markup describes a list even if styling changes.
<ul> <li>Notebook</li> <li>Pencil</li> <li>Ruler</li></ul>Three items form one list. Try changing their order: the collection still has the same meaning.
Nest a sublist
Place a nested list within the li that introduces it. Do not put a ul directly inside another ul as a sibling of the list items.
<ul> <li> Fruit <ul> <li>Apple</li> <li>Pear</li> </ul> </li> <li>Vegetables</li></ul>The fruit item contains a two-item sublist; Vegetables remains at the outer level.
Keep list meaning independent of appearance
Do not type a bullet character in every paragraph to imitate a list. Real list markup makes the item relationships available to assistive technology. If rearranging the items changes the intended procedure or ranking, use an ordered list (ol, covered next).
<p>Workshop materials:</p><ul> <li> Paper and <strong>scissors</strong> </li> <li>Glue</li></ul>An item may contain inline markup; both items remain part of the same list.
Practice and next steps
Create a two-level list of supplies, then complete the exercise. Next, learn how numbered lists represent order.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
HTML Unordered Lists: Items and Nested Lists — Knowledge Check
Check the core concepts from this lesson.
Which collection is best represented by ul?
Where does a nested ul belong?
Why use li instead of paragraphs with manually typed bullets?
You are marking ingredients whose order does not matter. Which structure is appropriate?
Which markup has a valid nested list structure?