Lists
Lists provide a way to order and structure sections of text.
Unordered lists
Use unordered (or bulleted) lists when the order of the items doesn’t matter.
<ul>
<li>Milk</li>
<li>Bread</li>
<li>Eggs</li>
<li>Flour</li>
</ul>
- Milk
- Bread
- Eggs
- Flour
You can nest lists.
- Python
- Java
- Front-end
- HTML
- CSS
- JavaScript
- Images
- PHP
Ordered lists
Use ordered (or numbered) lists when the order of the items does matter.
<ol>
<li>First do this</li>
<li>Then do this</li>
<li>Finally, do this</li>
</ol>
- One
- Two
- Three
- Four
- Five
- Six
- Seven
- Eight
- Nine
- Ten
Use the type attribute to change the numbering scheme:
1for numbers (default)Afor uppercase lettersafor lowercase lettersIfor uppercase Roman numeralsifor lowercase Roman numerals
- One
- Two
- Three
- Four
- Five
- Six
- Seven
- Eight
- Nine
- Ten
Nested ordered lists restart their count values for the new list.
- One
- Two
- Three
- Aye
- Bee
- Cee
- Dee
- Four
- Five
- Six
It’s OK to mix and match list types.
- One
- Two
- Three
- Firefly
- Star Wars
- Star Trek
- Babylon 5
- Blake’s 7
- Four
- Five
- Six
Use the start attribute to change the order start value. This is useful for when you need to split lists. It takes a number value, regardless of what the type attribute is set to.
- Eleven
- Twelve
- Thirteen
Use the reversed attribute for a count down to one.
- One
- Two
- Three
- Four
- Five
- Six
- Seven
- Eight
- Nine
- Ten
If you use a start value and reversed, the list can count down into the negatives.
- One
- Two
- Three
- Four
- Five
- Six
- Seven
- Eight
- Nine
- Ten
List item
Use the <li> element for list items in ordered or unordered lists.
<ol>
<li>List item one</li>
</ol>
Use the value attribute to change the value of the item number. If there is no value attribute on the next item, the list will resume the count at that number.
- One
- Two
- Three
- Four
- Five
- Six
- Seven
- Eight
- Nine
- Ten
Definition lists
Use definition lists to define key-value pairs. This is great for glossaries.
<dl>
<dt>Term</dt>
<dd>Descriptor</dd>
<dt>Term</dt>
<dd>Descriptor</dd>
</dl>