Not well known attributes for ordered list in HTML
In html exist the ol tag that allow you to show an ordered list.
1 | <ol> |
and for the above code the result is the following:
But what about if you want to change the order number? You can use the value attribute for the li tag.
1 | <ol> |
and the result will be:
Great, but there is another attribute that may be useful and give you the same result with less code. I am talking about the reversed attribute
1 | <ol reversed> |
much better because of the “less code” part!
Ok but now you have a section where you need to show the Top Ten Fruits. I know! You are thinking in an easy solution, just mix the reversed attribute with the value attribute, right?
1 | <ol reversed> |
Sure, that get the job done, but in this case there is other way using the start attribute.
1 | <ol reversed start="10"> |
Good now you can have the same behavior but using only attributes for the ol tag.
Browser Support
All these examples will work fine in basically every browser, but worth mentioning a couple of things:
- start attribute for the ol tag was deprecated in html 4, but still supported in html 5.
- value attribute for the li tag was deprecated in html 4, but still supported in html 5.
Hope it helps!