If you find this helpful, please click the Google |


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
- an optional <caption> tag
- optional <colgroup> tags and/or <col/> tags
- an optional <thead> tag
- an optional <tfoot> tag
- one or more <tr> tags either directly under the table element or inside a tbody element
- 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
<body> ... ... flow content expected ... <ol> <li> ... flow content ... </li> ... </ol> ... </body>
Make sure you understand the difference between a tag and element and are familiar with the definitions of namespace and other HTML terms.
- Code a ol element inside an element where flow content is allowed.
- 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. - Inside the ol element, between the
<ol>
starting tag and the</ol>
ending tag, code the li elements for the list items. - 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 |
reversed="reversed" | |
start | |
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> <ol> <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> </ol>
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.