Describes the usage of the ol tag in HTML5 and the html5ol tag

Source: Internet
Author: User

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
  1. <Ol>
  2. <Li> Coffee </li>
  3. <Li> Tea </li>
  4. </Ol>
  5. <Ol>
  6. <Li start = "60"> Coffee </li>
  7. <Li> Tea </li>
  8. </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
  1. <Ol>
  2. <Li> potato </li>
  3. <Li> onion </li>
  4. <Li> carrot </li>
  5. <Li> tenderloin </li>
  6. </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
  1. <Ol reversed = "reversed">
  2. This is the method inherited from XHTML. In fact, you can directly write
  3. <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
  1. <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
  1. <Ol>
  2. <Li value = "2"> potato </li>
  3. <Li value = "1"> onion </li>
  4. <Li value = "3"> carrot </li>
  5. <Li value = "4"> tenderloin </li>
  6. </Ol>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.