In HTML, the <ol> element is used to create an ordered list. An ordered list is a list of items where each item is preceded by a numerical or alphabetical indicator.

 Here's the basic syntax for an ordered list:

<ol>
    <li>Item 1</li>
    <li>Item 2</li>
    <!-- Add more list items if needed -->
</ol>
  • <ol>: Represents the entire ordered list.
  • <li>: Represents each individual list item within the ordered list.

Here's an example of an HTML ordered list:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HTML Ordered List Example</title>
</head>
<body>

    <h2>Fruits</h2>

    <ol>
        <li>Apple</li>
        <li>Orange</li>
        <li>Banana</li>
        <li>Grapes</li>
    </ol>

</body>
</html>

In this example:

  • The <ol> element contains four <li> elements, each representing a different fruit.
  • The list items are automatically numbered in ascending order.
     

You can customize the numbering style of the ordered list using the type attribute:

  1. type="1" (default): Numbers (1, 2, 3,...)
  2. type="A": Uppercase letters (A, B, C,...)
  3. type="a": Lowercase letters (a, b, c,...)
  4. type="I": Uppercase Roman numerals (I, II, III,...)
  5. type="i": Lowercase Roman numerals (i, ii, iii,...)
<ol type="A">
    <li>Item 1</li>
    <li>Item 2</li>
</ol>

Remember that the type attribute is optional, and if omitted, the default numbering style (numeric) will be applied.