Visit Mozilla.org

HTML:Element:ol

From MDC

[edit] Summary

Ordered list element is used to define an ordered or numbered list of items. The numbering style comes in many forms, including letters, Roman numerals, and regular numerals. The individual items within the list are specified by list item (<li>) elements included with the <ol> element.

[edit] Attributes

start Deprecated
Specifies the start value for numbering the individual list items. Although the ordering type of list elements might be Roman numerals, such as XXXI, or letters, the value of start is always represented as a number. To start numbering elements from the letter "C", use <ol type="A" start="3">.
type Deprecated
Indicates the numbering type: a indicates lowercase letters, A indicates uppercase letters, i indicates lowercase Roman numerals, I indicates uppercase Roman numerals, and 1 indicates numbers. Type set in an <ol> element is used for the entire list unless a type attribute is used within an enclosed <li> element. This attribute is deprecated, use CSS list-style-type property instead.
compact Deprecated
Indicates that the list should be rendered in a compact style. The interpretation of this attribute depends on the user agent. It doesn't work in all leading browsers.

[edit] Examples

[edit] Simple example

  <ol>
    <li>first item</li>
    <li>second item</li>
    <li>third item</li>
  </ol>

Above HTML will output:

  1. first item
  2. second item
  3. third item

[edit] Using start property

  <ol start="7">
    <li>first item</li>
    <li>second item</li>
    <li>third item</li>
  </ol>

Above HTML will output:

  1. first item
  2. second item
  3. third item

[edit] Nesting list

  <ol>
    <li>first item</li>
    <li>second item      <!-- Look, the closing </li> tag is not placed here! -->
      <ol>
        <li>second item first subitem</li>
        <li>second item second subitem</li>
        <li>second item third subitem</li>
      </ol>
    </li>                <!-- Here is the closing </li> tag -->
    <li>third item</li>
  </ol>

Above HTML will output:

  1. first item
  2. second item
    1. second item first subitem
    2. second item second subitem
    3. second item third subitem
  3. third item

[edit] Nested <ol> and <ul>

  <ol>
    <li>first item</li>
    <li>second item      <!-- Look, the closing </li> tag is not placed here! -->
      <ul>
        <li>second item first subitem</li>
        <li>second item second subitem</li>
        <li>second item third subitem</li>
      </ul>
    </li>                <!-- Here is the closing </li> tag -->
    <li>third item</li>
  </ol>

Above HTML will output:

  1. first item
  2. second item
    • second item first subitem
    • second item second subitem
    • second item third subitem
  3. third item

[edit] Notes

You can nest as many lists as you want, <ul> and <ol> in any order.

To change indent of list, use CSS margin property.

[edit] See also


HTML Elements
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
(Quick Links: HTML Element Cross Reference, HTML Category)