<ol> tag

HTML <ol> tag

The <ol> tag  creates an Ordered list. Ordered list is also called as numbered list because list items are marked with numbers.

To create the list of items inside the <ol> tag, you should always code the <li> tag.

Syntax:
<ol>
   <li>item-1</li>
   <li>item-2</li>
   <li>….</li>
   <li>item-n</li>
<ol>

Example

<ol>
  <li>January</li>
  <li>February</li>
  <li>March</li>
  <li>April</li>
  <li>May</li>
  <li>June</li>
  <li>July</li>
  <li>August</li>
  <li>September</li>
  <li>October</li>
  <li>November</li>
  <li>December</li>
</ol>

Default CSS values

It has the following default values:

display: block;
list-style-type: decimal;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 0;
margin-right: 0;
padding-left: 40px;

How Browser will display

Block.

Difference between HTML4.01, XHTML and HTML5

HTML4 XHTML HTML5
In HTML4.01,the start and type attributes are deprecated NA HTML5 supports the start and type attributes. The compact attribute is deprecated. The reversed attribute is a new attribute added in HTML5.

Attributes used with <ol> tag

Attribute Description
reversed Describes the width of the element in HTML5.
compact Makes the items compact by reducing the indents and spacing between the lines.
(HTML5 does not support this attribute, use CSS instead).
start Ordered list start value is specified here.
(HTML4 does not support this attribute when it is used with the <ol> tag).
In HTML5, it was reintroduced.
type Numering type of the ordered list.
(HTML4 does not support this attribute when it is used with the <ol> tag). In HTML5, it was reintroduced. The types are -
  • a
  • A
  • i
  • I
  • 1 - This is the default value.
  • Global Attributes

    The <ol> tag supports Global attributes.

    Event Attributes

    The <ol> tag supports Event attributes.

    Supporting Browsers

    supporting-browsers for tags

    Related Tags

    <li>, <ul>, <dl>, <dd> and <dt> tags.

    Tutorials for all brains!