docs.rodeo

MDN Web Docs mirror

    : The Ordered List element

{{HTMLSidebar}} 

The <ol> HTML element represents an ordered list of items — typically rendered as a numbered list.

{{EmbedInteractiveExample("pages/tabbed/ol.html", "tabbed-shorter")}} 

Attributes

This element also accepts the global attributes.

Usage notes

Typically, ordered list items display with a preceding marker, such as a number or letter.

The <ol> and {{HTMLElement("ul")}}  (or the synonym {{HTMLElement("menu")}} ) elements may nest as deeply as desired, alternating between <ol>, <ul> (or <menu>) as needed.

The <ol> and {{HTMLElement("ul")}}  elements both represent a list of items. The difference is with the <ol> element, the order is meaningful. For example:

To determine which list to use, try changing the order of the list items; if the meaning changes, use the <ol> element — otherwise you can use {{HTMLElement("ul")}}  otherwise, or {{HTMLElement("menu")}}  if your list is a menu.

Examples

Basic example

<ol>
  <li>Fee</li>
  <li>Fi</li>
  <li>Fo</li>
  <li>Fum</li>
</ol>

Result

{{EmbedLiveSample("Basic_example", 400, 100)}} 

Using Roman Numeral type

<ol type="i">
  <li>Introduction</li>
  <li>List of Grievances</li>
  <li>Conclusion</li>
</ol>

Result

{{EmbedLiveSample("Using_Roman_Numeral_type", 400, 100)}} 

Using the start attribute

<p>Finishing places of contestants not in the winners' circle:</p>

<ol start="4">
  <li>Speedwalk Stu</li>
  <li>Saunterin' Sam</li>
  <li>Slowpoke Rodriguez</li>
</ol>

Result

{{EmbedLiveSample("Using_the_start_attribute", 400, 100)}} 

Nesting lists

<ol>
  <li>first item</li>
  <li>
    second item
    <!-- closing </li> tag is not here! -->
    <ol>
      <li>second item first subitem</li>
      <li>second item second subitem</li>
      <li>second item third subitem</li>
    </ol>
  </li>
  <!-- Here's the closing </li> tag -->
  <li>third item</li>
</ol>

Result

{{EmbedLiveSample("Nesting_lists", 400, 150)}} 

Unordered list inside ordered list

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

Result

{{EmbedLiveSample("Unordered_list_inside_ordered_list", 400, 150)}} 

Technical summary

Content categories Flow content, and if the <ol> element's children include at least one `{{HTMLElement("li")}}`  element, palpable content.
Permitted content Zero or more `{{ HTMLElement("li") }}` , `{{HTMLElement("script")}}`  and `{{HTMLElement("template")}}`  elements.
Tag omission None, both the starting and ending tag are mandatory.
Permitted parents Any element that accepts flow content.
Implicit ARIA role list
Permitted ARIA roles directory, group, listbox, menu, menubar, none, presentation, radiogroup, tablist, toolbar, tree
DOM interface `{{DOMxRef("HTMLOListElement")}}` 

Specifications

{{Specifications}} 

Browser compatibility

{{Compat}} 

See also

In this article

View on MDN