Subscribe

HTML ordered list options

✍️

Did you know the HTML ordered list has many options?

13 Mar, 2021 Β· 2 min read

I’m sure we all know the ordered list, which can be created by using a <ol> (Ordered list) element.

A basic structure looks like this:

<ol>
  <li>Number 1</li>
  <li>Number 2</li>
  <li>Number 3</li>
</ol>

And it will return this:

  1. Number 1
  2. Number 2
  3. Number 3

But did you know there’s super cool stuff we can do with ordered lists?

Defining an ordered list type

By default, it will show the numbers as you can see above, but did you know we can specify the type in HTML?

<ol type="I">
  <li>Daily</li>
  <li>Dev</li>
  <li>Tips</li>
</ol>

Will return:

I. Daily II. Dev III. Tips

We can use the following types:

  • 1: The default numeric list
  • I: Uppercase roman numbers
  • i: Lowercase roman numbers
  • A: Uppercase letters
  • a: Lowercase letters

Set the start number for ordered lists

Next up is the start. By default, a list will start on one, but we can manually offset this.

<ol start="5">
  <li>Daily</li>
  <li>Dev</li>
  <li>Tips</li>
</ol>

This will render the following. It can be super useful in a list with paragraphs between.

  1. Daily
  2. Dev
  3. Tips

Reverse an HTML ordered list

Another cool thing we can do with lists is reverse them. It’s just as easy as adding the reversed tag.

<ol reversed>
  <li>Daily</li>
  <li>Dev</li>
  <li>Tips</li>
</ol>

This will result in the following:

3 Daily 2 Dev 1 Tips

You can try all these out in the following Codepen.

See the Pen HTML ordered list options by Chris Bongers (@rebelchris) on CodePen.

Thank you for reading, and let’s connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter

Spread the knowledge with fellow developers on Twitter
Tweet this tip
Powered by Webmentions - Learn more

Read next πŸ“–

Submit button outside the form

4 Dec, 2022 Β· 1 min read

Submit button outside the form

Trying out native dialog modals

8 Aug, 2022 Β· 3 min read

Trying out native dialog modals

Join 2099 devs and subscribe to my newsletter