<ol>

Term side of the Card.
Topic: Lists
Unit title: <ol>
Categories: Tag
Explanation side of the Card

Explanation: The element that creates an ordered list of items, where each item is preceded by a number or letter. It's used when the sequence or ranking of list items is important.

Browser compatibility:
  • The chrome browser supports this feature starting from version 1.
  • The edge browser supports this feature starting from version 12.
  • The firefox browser supports this feature starting from version 1.
  • The safari browser supports this feature starting from version 4.
Availability: 

Example

Wronghtml
<p>1. Preheat the oven</p>
<p>2. Mix the dough</p>
<p>3. Bake</p>
Righthtml
<ol>
  <li>Preheat the oven</li>
  <li>Mix the dough</li>
  <li>Bake</li>
</ol>

<ol> numbers items automatically and tells screen readers how many steps there are.

Common mistakes

  • Typing '1.' and '2.' into paragraphs instead of using <ol>.
  • Hiding numbers with CSS for a list where order matters to the reader.

Key points

  • Numbers come from <ol>, not typed into the item text.
  • A list that continues elsewhere uses start, not manual numbering.
  • Only <li> elements are direct children of the <ol>.

Interview questions

How do I start an ordered list at 5?

Add start="5" to the <ol>. To change one item's number, set value on that <li>.

How do I make a countdown list?

Add the reversed attribute to the <ol>, and the numbers count down from the item count or from start.

How do I use letters or roman numerals?

Use type="a", type="A", type="i" or type="I" on the <ol>, or set list-style-type in CSS.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy