Back to subject
HTML5/HTML Lists

Choose the Right List

Practical lesson

Let's read three list patterns: unordered, ordered, and nested lists.

- Start with <ul> when the order of the items does not matter. - Put each item inside its own <li>. - Use <ol> when the order carries meaning, such as steps in a process. - The numbers are generated by the browser, so you do not need to type 1, 2, and 3 yourself. - A nested list starts a new <ul> or <ol> inside a parent <li>. - In <li>Frontend<ul><li>HTML</li><li>CSS</li></ul></li>, Frontend is the parent item and HTML/CSS are its sub-items. - The nested list must be inside the parent <li> so the browser can understand the relationship. - Most browsers visually indent nested lists and often change the bullet shape at deeper levels. - Do not choose <ol> or <ul> only because you like its visual appearance; choose it based on whether order matters.

The practical goal is to understand both the list type and the nesting relationship.

Try it yourself
Code

Starter example

Code
<h2>My Hobbies</h2>
<ul>
  <li>Reading</li>
  <li>Coding</li>
  <li>Drawing</li>
</ul>

<h2>Morning Steps</h2>
<ol>
  <li>Wake up</li>
  <li>Eat breakfast</li>
  <li>Start learning</li>
</ol>
Live preview