HTMLbeginner 6 min
Group items in ordered and unordered lists, and nest lists inside each other.
How to build bulleted lists, numbered lists, and lists inside lists.
Menus, steps, shopping carts and navigation bars are all lists. HTML has proper tags for them so that browsers and screen readers know "these items belong together".
There are two main list tags:
<ul>: an unordered list (bullets). Order does not matter.<ol>: an ordered list (numbers). Order matters.Each item inside either one is an <li> (list item). Only <li> tags should sit directly inside a <ul> or <ol>.
To nest a list, put a new <ul> or <ol> inside an <li>.
<ul> has three <li> items, shown with bullets.<ul>. The browser indents it.<ol> numbers its items 1, 2, 3 automatically.Make a numbered list of your morning routine, then add a nested bulleted list under one step.
<p>1. Boil water</p>. Use <ol> and <li>.<ul> without an <li>.<li> too early when nesting. The nested list belongs inside the item.<ul> is bullets, <ol> is numbers, <li> is each item.<li> to make sub-items.You finished the HTML beginner section. Next up in the full course: tables and forms.
<h2>Shopping</h2>
<ul>
<li>Milk</li>
<li>Bread</li>
<li>Fruit
<ul>
<li>Apples</li>
<li>Bananas</li>
</ul>
</li>
</ul>
<h2>Make tea</h2>
<ol>
<li>Boil water</li>
<li>Add tea bag</li>
<li>Pour water</li>
</ol>