The <ol>
represents an ordered list of items, typically rendered as a numbered list.
Content categories |
Flow content, and if the <ol> element's children include at least one <li> element, palpable content. |
---|---|
Permitted content | Zero or more <li> elements, which in turn often contain nested <ol> or <ul> elements. |
Tag omission | None, both the starting and ending tag are mandatory. |
Permitted parents | Any element that accepts flow content. |
Permitted ARIA roles |
directory , group , listbox , menu , menubar , radiogroup , tablist , toolbar , tree , presentation
|
DOM interface | HTMLOListElement |
This element includes the global attributes.
compact
Warning: Do not use this attribute, as it has been deprecated: the <ol>
element should be styled using CSS. To give an effect similar to the compact
attribute, the CSS property line-height
can be used with a value of 80%
.
reversed
HTML5
start
HTML5
<ol start="3">
. Note: This attribute was deprecated in HTML4, but reintroduced in HTML5.
type
'a'
indicates lowercase letters,'A'
indicates uppercase letters,'i'
indicates lowercase Roman numerals,'I'
indicates uppercase Roman numerals,'1'
indicates numbers (default).The type set is used for the entire list unless a different type
attribute is used within an enclosed <li>
element.
Note: This attribute was deprecated in HTML4, but reintroduced in HTML5.
Unless the value of the list number matters (e.g. in legal or technical documents where items are to be referenced by their number/letter), the CSS list-style-type
property should be used instead.
list-style-type
property.<ol>
and <ul>
elements.<ol>
and <ul>
both represent a list of items. They differ in the way that, with the <ol>
element, the order is meaningful. As a rule of thumb to determine which one to use, try changing the order of the list items; if the meaning is changed, the <ol>
element should be used, else the <ul>
is adequate.<ol> <li>first item</li> <li>second item</li> <li>third item</li> </ol>
Above HTML will output:
<ol type="i"> <li>foo</li> <li>bar</li> <li>spam</li> </ol>
Above HTML will output
i. foo
ii. bar
iii. spam
start
attribute<ol start="7"> <li>first item</li> <li>second item</li> <li>third item</li> </ol>
Above HTML will output:
<ol> <li>first item</li> <li>second item <!-- closing </li> tag 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>
Above HTML will output:
<ol> <li>first item</li> <li>second item <!-- closing </li> tag 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>
Above HTML will output:
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of '<ol>' in that specification. | Living Standard | No change since last W3C snapshot, HTML5. |
HTML5 The definition of 'HTMLOListElement' in that specification. | Recommendation | Added reversed and start attributed; un-deprecated type
|
HTML 4.01 Specification The definition of '<ol>' in that specification. | Recommendation | Deprecated compact and type . |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | Yes | Yes | 1 | Yes | Yes | Yes |
compact
|
Yes | Yes | 1 | Yes | Yes | Yes |
reversed |
18 | ? | 18 | No | Yes | 6 |
start |
Yes | Yes | 1 | Yes | Yes | Yes |
type
|
Yes | Yes | 1 | Yes | Yes | Yes |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | Yes | Yes | Yes | 4 | Yes | Yes | Yes |
compact
|
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
reversed |
Yes | Yes | ? | 18 | Yes | Yes | Yes |
start |
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
type
|
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
<ul>
, <li>
, <menu>
and the obsolete <dir>
;<ol>
element: list-style
property, useful to choose the way the ordinal is displayed,line-height
property, useful to simulate the deprecated compact
attribute,margin
property, useful to control the indent of the list.
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ol