Describes the usage of the ol tag in HTML5 and the html5ol tag
This article describes how to use the ol tag in HTML5. It is the basic knowledge of HTML5 beginners. For more information, see
Definition and usage
<Ol> the tag definition is an ordered list.
Differences between HTML 4.01 and HTML 5
In HTML 4.01, the "start" attribute is not supported and is allowed in HTML 5.
In HTML 4.01, the "compact" and "type" attributes are not supported. In HTML 5, these two attributes are no longer supported.
Tips and comments
Tip: Use CSS to define the list type.
Example
Copy XML/HTML Code to clipboard
- <Ol>
- <Li> Coffee </li>
- <Li> Tea </li>
- </Ol>
- <Ol>
- <Li start = "60"> Coffee </li>
- <Li> Tea </li>
- </Ol>
OL tag serial number control provided by HTML5
OL, which displays data in an ordered list, automatically adds a number to the data. However, sometimes the data is not numbered from 1, or the numbers are arranged in descending order, or the numbers are completely messy, in this case, you need to use some parameters provided for the OL tag in html5. Unfortunately, it is not compatible with IE.
Now, we have an HTML document like this.
Copy XML/HTML Code to clipboard
- <Ol>
- <Li> potato </li>
- <Li> onion </li>
- <Li> carrot </li>
- <Li> tenderloin </li>
- </Ol>
It is displayed as follows:
By default, these sequence numbers increase progressively from 1. What if we need to arrange the sequence numbers in the OL label in reverse order? You only need to add a reserved attribute to OL.
Copy XML/HTML Code to clipboard
- <Ol reversed = "reversed">
- This is the method inherited from XHTML. In fact, you can directly write
- <Ol reversed>
This is already in line with the HTML5 standard. With this added, you can get this result.
Chrome and Firefox are okay, but IE is not compatible with it (at least I tested IE10 is incompatible ). Well, now I just want to know about this function. I will not discuss it again if I don't Implement IE.
What if I don't want it to start from 1? For example, to make it start from 3, we can add the start attribute to the OL tag and set it to 3.
Copy XML/HTML Code to clipboard
- <Ol start = "3">
Finally, how can we do things that are completely irregular but orderly? For example, I want to arrange 2, 1, 3, and 4. What should I do? In fact, you only need to add the value attribute to LI to control the serial number.
Copy XML/HTML Code to clipboard
- <Ol>
- <Li value = "2"> potato </li>
- <Li value = "1"> onion </li>
- <Li value = "3"> carrot </li>
- <Li value = "4"> tenderloin </li>
- </Ol>