← Web basics: HTML, CSS and JavaScript
Lists
Bulleted lists with ul, numbered lists with ol.
Many things on the web are lists: menus, ingredients, steps, search results. HTML has two main kinds. <ul> is an unordered list (bullets), for items where order does not matter. <ol> is an ordered list (numbers), for steps or rankings where order matters. Inside either one, each item is an <li> (list item). Using real lists, not lines of text with dashes, lets screen readers say "list, 5 items", which helps people know what is coming.
<h2>Packing list</h2>
<ul>
<li>Water bottle</li>
<li>Sun hat</li>
<li>Snacks</li>
</ul>
<h2>How to plant a seed</h2>
<ol>
<li>Fill a pot with soil.</li>
<li>Push the seed in 1 cm deep.</li>
<li>Water it gently.</li>
</ol>The packing list could be in any order, so it uses bullets. The planting steps must happen in order, so the browser numbers them for you.
Lists can be nested: put a whole <ul> inside an <li> to make sub-items.
Only <li> elements go directly inside <ul> or <ol>. Headings and paragraphs go inside an <li> if you need them.