How to create HTML list in descending order numbers?
Answer: By specifying
reversed keyword within the
The ordered list is used to add multiple items with some sequence or order. Generally, the ordered list is created with ascending order numbers.
But it is also possible to create the HTML ordered list in descending order. Let's learn how to do this.
Creating a list in descending order
We can specify the numbers in the ordered list in descending order. This can be done by adding the
reversed attribute within the
<ol> tag. Here is an example to create an ordered list with descending order numbers.
<h2> Reversed ordered List </h2>
<li> case 1</li>
<li> case 2</li>
<li> case 3</li>
<li> case 4</li>
Here is the output of the above program.
Descending order for roman numbers
reversed attribute can be used to reverse the order of the roman numbers too. Here, we have added
type="I" which will create an uppercase roman number, and along with it, we have added the reversed attribute so the order can be reversed.
So, we can easily create a descending order number list in HTML. Use the reversed attribute for it. It is to be noted that it will only reverse the numbers and not the position of the items.