7.2 Ordered Lists (ol) and Numbering Types
An ordered list (<ol>) displays a sequence of items marked by numbers, letters or Roman numerals. It’s ideal when the order of steps or ranking matters.
1. Basic Syntax
Use <ol> to start the list and <li> for each item.
- First item
- Second item
- Third item
2. Key Attributes of <ol>
| Attribute | Description | Values |
|---|---|---|
type |
Specifies the marker style (numbering type). | '1', 'A', 'a', 'I', 'i' |
start |
Defines the starting value for the first list item. | Any positive integer |
reversed |
Reverses the numbering sequence. | Boolean attribute (just present) |
value (<li>) |
Overrides the number for that specific item. | Any integer |
3. Numbering Types (type)
The type attribute changes the marker of all items in the list.
- Item one
- Item two
- Item three
- Option A
- Option B
- Option C
- step a
- step b
- step c
- Phase I
- Phase II
- Phase III
- part i
- part ii
- part iii
4. Starting at a Custom Value (start)
Use start when you want the first item to begin at a number other than 1.
- Jump to five
- Then six
- Seven
5. Reversed Ordering (reversed)
The reversed boolean attribute flips the numbering sequence, so the last item shows “1”. Combine with start to set the top number.
- Last step
- Middle step
- First step
- Ten
- Nine
- Eight
6. Overriding Individual Values (<li value=’…’>)
Within an ordered list, individual <li> elements can override their own numbering using the value attribute.
- Item one
- Jump to ten
- Eleven follows
- Huge number
- One hundred one
7. Nesting Ordered Lists
You can nest ordered lists inside <li> elements. Nested lists inherit numbering unless you specify a new type.
- First level
- Sublevel a
- Sublevel b
- Second level
- Sublevel V
- Sublevel VI
8. Accessibility and Semantic Tips
- Use ordered lists for sequences where order matters (recipes, instructions, rankings).
- Ensure nested lists remain clear to screen readers by providing context via headings or
aria-label. - Avoid using
typefor styling—consider CSS (list-style-type) in production, sincetypeis obsolete in strict HTML5.
Leave a Reply
You must be logged in to post a comment.