Description
The HTML element <ol>
is used to define an ordered list of items, where each list item is defined using the <li>
element.
The ordered list is displayed with a number in front of each list item, and the numbering style can be controlled with the list-style-type
CSS property.
The below table summarizes its usage.
Usage Details | |
Placement | It is defined as a Block element. |
Contents | It can contain one or more <li> elements. |
Tags | Both the opening and closing tags are required. |
Versions | HTML 2, 3.2, 4, 4.01, 5 |
Syntax
Here is the basic syntax of the <ol>
element.
<ol>...</ol>
Examples
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example - HTML Element ol</title>
</head>
<body>
<h1>HTML Ordered List</h1>
<ol>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ol>
</body>
</html>
Attributes
The following table shows the list of supported and unsupported attributes for the <ol>
element.
Attribute Type | Details |
Element-Specific Attributes | The tag <ol> has some element-specific attributes listed in the below table. |
Global Attributes | Like all other HTML tags, the tag <ol> supports the HTML Global Attributes. |
Event Attributes | The tag <ol> also supports the HTML Event Attributes. |
Here is a list of attributes that are specific to the <ol>
element.
Attribute | Value | Required | Description |
reversed |
reversed |
No | This Boolean attribute specifies that the items of the list are specified in reverse order. |
type |
1, A, a, I, i | No | Specify the bullet or numbering type for the list item. |
compact |
compact |
No | Obsolete This Boolean attribute specifies that the list should be rendered in a compact style. |
start |
number | No | Specifies the starting number of the first item in an ordered list. |
Browser Compatibility
The tag <ol>
is supported in all modern browsers.
- Google Chrome 1+
- Internet Explorer or Edge 2+
- Firefox 1+
- Apple Safari 1+
- Opera 4+