HTML Elements
Lists
HTML provides us with two slighly different tags for creating lists:
<ul> for unordered lists and <ol> for ordered lists. We can
usually default to unordered lists and switch to ordered lists when
the order of the list items matter.
We can nest lists as deep as we want, as long as we always be wrap the
content in <li> tags (list items).
Code example: unordered
<ul><li>The Lathe of Heaven</li><li>Rocannon's World</li><li>The Word for World is Forest</li></ul>
produces the unordered list below.
- The Lathe of Heaven
- Rocannon's World
- The Word for World is Forest
Read more on MDN
<ul>: The Unordered List element
Code example: ordered
<ol><li>Turn off the computer</li><li>Go outside</li><li>Contemplate the meaning of life</li></ol>
produces the ordered list below.
- Turn off the computer
- Go outside
- Contemplate the meaning of life
Read more on MDN
<ol>: The Ordered List element
Code example: nested
<ul><li>Fantasy<ol><li>The Eye of the World</li><li>The Lies of Locke Lamora</li></ol></li><li>Science fiction<ol><li>Dune</li><li>Ender's Game</li></ol></li><li>Classics<ol><li>Of Mice and Men</li><li>Mockingbird</li></ol></li></ul>
produces the nested list below.
- Fantasy
- The Eye of the World
- The Lies of Locke Lamora
- Science fiction
- Dune
- Ender's Game
- Classics
- Of Mice and Men
- Mockingbird
Test yourself
Description
Add two lists:
- one unordered list with at least two types of food you like
- one ordered list with at least two of your favorite movies
Tests
- 1 You should create an unordered list.
- 2 Your unordered list element should have a closing tag.
- 3 Your unordered list element should have at least two non-empty list items.
- 4 You should create an ordered list.
- 5 Your ordered list element should have a closing tag.
- 6 Your ordered list element should have at least two non-empty list items.
Preview