Learn how to use ordered and unordered lists in HTML.
Lists are used all the time on web pages as a helpful way to organize information. In this tutorial, we’ll learn how to add lists to our web pages using HTML and practice making different kinds of lists.
Unordered Lists
Unordered lists are formatted using bullets and look like this:
The ul Tag
The <ul>
tag defines the entire unordered list.
The li Tag
The <li>
tag defines each individual list item inside a list.
Explore!
Take a look at this example of how to use an unordered list. Play around and change the items in the list. Try to add or delete an item. Click on RUN after each change to see its effect. Can you form a new second list?
You Try!
Use the unordered list tag <ul>
to create a webpage listing at least 5 bucket list tasks that you’d like to complete one day.
Be careful of these common errors:
<ul>
tag too soon! This closing tag should be at the very end of your list. All <li>
tags should be placed inside the <ul>
tags.Ordered Lists
Ordered lists are formatted using bullets and look like this:
The ol Tag
The <ol>
tag defines the entire ordered list.
The li Tag
The <li>
tag is still used to define each individual list item inside the list.
You Try!
Use the ordered list tag <ol>
to create a webpage that lists your top five favorite movies.
Nested Lists
If one list is not enough, you can create a list within a list! This is called a nested list. Here is an example:
There are no new tags needed to create a nested list. Using nested tags can get messy however. You’ll want to keep track of your opening and closing tags by indenting with each nested list. This is how the list above was formated using HTML:
You Try!
Create a nested to-do list for the week. The days of the week should be listed as an unordered list and the items to be completed on each day should be written as an ordered list. Here is a sample of what this might look like:
Now that you know how to create and format lists using HTML, take it one step further and learn how to format tables!