HTML <ol> Tag

HTML <ol> tag is used to create an ordered list, which contains elements in a certain sequence.

Each element of the ordered list starts with the opening <li> tag and ends with the closing tag </li>. In addition to the text, the <li> tag may include other HTML elements (lists, images, headings, paragraphs, etc.).

The following values can be used as numbering elements: Arabic numbers (1, 2, 3, ...); uppercase Latin letters (A, B, C, ...); lowercase latin letters (a, b, c, ...); Roman capital numbers (I, II, III, ...); Roman lowercase numbers (i, ii, iii, ...). The type attribute is used to indicate the type of the numbered list.

If do not specify any additional attributes, then the content of the <ol> tag is by default numbered with Arabic numbers, starting with one.

If the CSS properties are applied to the <ol> tag, then the elements nested in the <li> tag inherit them.

Syntax

The <li> tag comes in pairs; the closing tag is required.

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <ol>
      <li>Appetizers</li>
      <li>Hot</li>
      <li>Salads</li>
    </ol>
    <ol start="50">
      <li>Cold drinks</li>
      <li>Hot drinks</li>
      <li>Ice-Cream</li>
    </ol>
    <ol type="A">
      <li>Coca-Cola</li>
      <li>Ice Tea</li>
      <li>Fanta</li>
    </ol>
  </body>
</html>

Result

In the given example we used the start attribute with the value "50".

CSS properties

To determine the type of numbering elements instead of the type attribute, you can use the CSS list-style-type property.

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <h2>Examples of ordered lists</h2>
    <ol style="list-style-type: upper-roman">
      <li>Cold drinks</li>
      <li>Hot drinks</li>
      <li>Ice-Cream</li>
    </ol>
    <ol style="list-style-type: hebrew">
      <li>Coca-Cola</li>
      <li>Fanta</li>
      <li>Ice Tea</li>
    </ol>
    <ol style="list-style-type: decimal">
      <li>Coca-Cola</li>
      <li>Fanta</li>
      <li>Ice Tea</li>
    </ol>
  </body>
</html>

Result

Attributes

Attribute Value Description
compact compact Reduces indents and spacing between lines.
Not supported in HTML5. Instead, we recommend to use CSS property line-height.
reversed reversed Indicates, that list elements should go in descending order (instead of the usual ascending order).
Not supported in Internet Explorer and Edge.
start number Sets the number from which the ordered list will begin. The value must be an integer, negative values may be used. When used with letters (type = "A" and type = "a"), the number indicated in the attribute value corresponds to the ordinal number of the letter in the alphabet. For example, start = "5", will correspond to the letter "E" and the list will begin with it. If start = "27" is specified, the list becomes two-digit ("27" = "AA", "28" = "AB", "29" = "AC" ...).
type 1
A
a
I
i
Defines the type of the list marker.

The <ol> tag supports the Global Attributes and the Event Attributes.

Browser support