0% completed
In this lesson, you'll learn how to create ordered (numbered) lists in HTML using the <ol>
tag. Ordered lists are perfect for displaying items in a specific sequence, such as steps in a process, rankings, or any content that benefits from numbering.
An HTML ordered list is a list where each item is automatically numbered by the browser. This is useful when the order of items matters.
The <ol>
tag is used to create ordered lists, and each list item is wrapped in an <li>
(list item) tag.
The basic syntax for creating an ordered list is as follows:
<ol> <li>First item</li> <li>Second item</li> <li>Third item</li> </ol>
<ol>
: The opening tag for the ordered list.<li>
: The list item tag used to define each item within the list.</ol>
: The closing tag for the ordered list.The <ol>
tag supports several attributes that allow you to customize the appearance and behavior of your ordered lists:
Let's explore below practical examples of using the <ol>
tag with different attributes.
This example demonstrates a simple ordered list without any additional attributes. The list items are numbered automatically by the browser.
Explanation:
<ol>
tag creates an ordered list of steps.<li>
tag represents a step in the account creation process.The type
attribute allows you to change the numbering style of the ordered list.
Common types include:
Type Attribute | Description | Example |
---|---|---|
type="1" | Numbers (default) | 1, 2, 3, 4, ... |
type="A" | Uppercase letters | A, B, C, D, ... |
type="a" | Lowercase letters | a, b, c, d, ... |
type="I" | Uppercase Roman numerals | I, II, III, IV, ... |
type="i" | Lowercase Roman numerals | i, ii, iii, iv, ... |
Explanation:
type="A"
attribute changes the numbering to uppercase letters (A, B, C, etc.).The start
attribute specifies the starting number of the ordered list. This is helpful when you want your list to begin with a number other than 1.
Explanation:
start="6"
attribute makes the list begin with the number 6.The reversed
attribute displays the ordered list in descending order, starting from a specified number or the default maximum number.
Explanation:
reversed
attribute reverses the numbering order.start="5"
attribute sets the starting number to 5, counting down to 1.This example combines multiple attributes to create a customized ordered list with a specific numbering style, order, and starting point.
Example: Customized Task List
Explanation:
type="i"
changes the numbering to lowercase Roman numerals (i, ii, iii, etc.).reversed
makes the list count downwards.start="5"
sets the starting number to 5, resulting in the list numbering as v, iv, iii, ii, i.Understanding how to effectively use ordered lists enhances the structure and clarity of your web content, making it more organized and user-friendly. In the next lesson, we'll explore HTML Unordered Lists, where you'll learn how to create bullet-point lists for items that don't require a specific order.
.....
.....
.....