HTML <ol> tag creates ordered lists, where list items are automatically numbered. It's structured with <ol> for the list, and <li> for each item. Lists can be customized with attributes like type and start.
Syntax:
<ol>
<li>Item1</li>
<li>Item2</li>
<li>Item3</li>
</ol>
Accepted attributes:
Attribute | Description |
---|---|
compact | Defines that the list should be compacted. Use CSS instead of the compact attribute in HTML5. |
reversed | Defines that the order of the list items should be descending (from high to low). |
start | Defines the starting number or alphabet for the ordered list. |
type | Defines the type of order for the list items. Options include numeric (1, 2, 3...), alphabetic (A, B, C...), lowercase alphabetic (a, b, c...), uppercase Roman numerals (I, II, III...), and lowercase Roman numerals (i, ii, iii...). |
HTML <ol> Tag Examples
Example 1: In this example, The <ol> tag in HTML creates an ordered list where each item is automatically numbered. here we have created an ordered list of Frontend Technologies.
<!DOCTYPE html>
<html>
<head>
<title>HTML Ordered Lists</title>
</head>
<body>
<h2>Welcome To GeeksforGeeks</h2>
<ol>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
<li>React.Js</li>
</ol>
</body>
</html>