<ol>
<ol> Tag
The <ol> element in HTML is used to create an ordered list, where items are automatically numbered in sequence by the browser.
Syntax
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
<ol> Demo
- Introduction
- Development
- Conclusion
<ol>
<li>Introduction</li>
<li>Development</li>
<li>Conclusion</li>
</ol>
Ordered List - type Attribute
The type attribute allows you to define different numbering formats for list items:
| Type | Description |
|---|---|
type="1" | Numbers (default) |
type="A" | Uppercase letters |
type="a" | Lowercase letters |
type="I" | Uppercase Roman numerals |
type="i" | Lowercase Roman numerals |
Examples
Numbered List
- Coffee
- Tea
- Milk
<ol type="1">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Uppercase Letters
- Coffee
- Tea
- Milk
<ol type="A">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Lowercase Letters
- Coffee
- Tea
- Milk
<ol type="a">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Roman Numbers - Uppercase
- Coffee
- Tea
- Milk
<ol type="I">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Roman Numbers - Lowercase
- Coffee
- Tea
- Milk
<ol type="i">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Attributes
reversed– Displays items in descending order.start– Specifies the starting number.type– Defines the numbering format (1,A,a,I,i).
Related List Elements
| Tag | Description |
|---|---|
<ul> | Creates an unordered list |
<ol> | Creates an ordered list |
<li> | Defines an item in a list |
<dl> | Defines a description list |
<dt> | Specifies a term in a description list |
<dd> | Provides a description of a term |
See Also
- Other List Elements:
<ul>,<li>,<menu> - CSS Styling Options:
list-style– Customizes numbering.counter– Manages nested lists.margin– Controls list indentation.
Conclusion
The <ol> tag in HTML is a versatile tool for creating ordered lists, allowing content to be presented in a sequential format. It offers customization options through attributes like type, start, and reversed to change the numbering style and order. By utilizing nested lists, developers can create complex structures within the list items.
Lists
Lists in HTML organize content into ordered (<ol>), unordered (<ul>), and definition (<dl>) lists, with items defined using (li>) or(dt>/<dd>) or enhancing content structure and readability.
<ul>
The HTML <ul> element generates an unordered list, showing list items (<li>) with bullet points. It is used to present items without a specific sequence.