HTML <ol> Tag for a Numbered List


ATTENTION: THIS PAGE IS Valid HTML 5 AND IS BEST VIEWED WITH HTML 5 - Please upgrade your browser or download one of the HTML 5 compatible browsers such as Mozilla Firefox, Chrome, Opera or IE 9 (March 14, 2011 or later). For more information see HTML 5 browsers.

If you find this helpful, please click the Google +1 Button to the left, if it is white, to make it turn blue or red. Thank you! (It also helps find this page again more easily.)

PDF mobile

The HTML <ol> Tag for Ordered Lists

Use the <ol> Tag for Numbered Lists in HTML 5

The <ol> tag is used for ordered lists in HTML. This tag is often used for numbered lists like the example of an ordered list below. For bulleted lists, use the <ul> tag instead.

Each list item in an ordered list is an li child element of the ol element, created using the <li> tag. In an ordered list, items are usually numbered but a different list item style can be specified to omit the numbers or use a bullet or image instead.

Here is an example of an ordered list using the ol element:

Child elements of a table element
  1. an optional <caption> tag
  2. optional <colgroup> tags and/or <col/> tags
  3. an optional <thead> tag
  4. an optional <tfoot> tag
  5. one or more <tr> tags either directly under the table element or inside a tbody element
  6. an optional <tfoot> tag

This is an actual working example of the <ol> tag example code below.

<ol> Tag Syntax

Rules for coding HTML ordered list elements
   ... flow content expected ...
         ... flow content ...

Make sure you understand the difference between a tag and element and are familiar with the definitions of namespace and other HTML terms.

  1. Code a ol element inside an element where flow content is allowed.
  2. Begin the ol element with a starting <ol> tag. The element name uses lower case letters and should be in the HTML namespace, which it will pick up automatically from the xmlns attribute on the <html> tag.
  3. Inside the ol element, between the <ol> starting tag and the </ol> ending tag, code the li elements for the list items.
  4. End the ol element with a matching </ol> closing tag.
Content of the ol element

The content of the ol element can only include HTML comments and li elements.

<ol> Tag Attributes

Attributes of the <ol> tag
global attributes In addition to the personal attributes of the <ol> tag below, any of the common HTML attributes can also be coded.
compact The compact boolean attribute was one of the attributes deprecated in HTML 4
type The type attribute was one of the attributes deprecated in HTML 4

<ol> Tag Examples

Examples of the ol tag in HTML 5
<ol> tag Example
(see <ol> tag demo above)
<h6>Child elements of a table element</h6>
<li>an optional <caption> tag</li>
<li>optional <colgroup> tags and/or <col/> tags</li>
<li>an optional <thead> tag</li>
<li>an optional <tfoot> tag</li>
<li>one or more <tr> tags either directly under the table element or inside a tbody element</li>
<li>an optional <tfoot> tag</li>

Changes in HTML 5 - <ol> Tag

What's new in HTML 5

The start attribute, which was removed from HTML 4 and XHTML, has been resurrected in HTML 5. In addition, the reversed="reversed" boolean attribute has been added.

Differences between HTML 5 and earlier versions of HTML

The following attributes should not be coded on the <ol> tag because they either have been deprecated or were never officially supported:

  • compact
  • type

The 2000-2010 Recommendations from the W3C HTML Working Group defined the HTML namespace for the ol element type name along with the names of all HTML element types. In older (pre-2000) versions of HTML, element type names were not associated with a namespace.

Valid HTML 5