HTML Ordered List (<ol>):

The HTML Ordered List (<ol>) element is used to create lists in which the order of items is significant. It is often employed when presenting information in a sequential or hierarchical manner. Here's a detailed guide on using the HTML Ordered List:

  1. Basic Syntax:
    • The (<ol>) element is used to create an ordered list.
    • List items within the ordered list are defined with the (<li>) (list item) element.
    <ol>
    <li>First Item</li>
    <li>Second Item</li>
    <li>Third Item</li>
    </ol> 
    Output:-
    1. First Item
    2. Second Item
    3. Third Item

  2. Type Attribute:
    • The type attribute can be used to specify the type of numbering or markers used in the ordered list.
    • Possible values include "1" (numbers), "A" (uppercase letters), "a" (lowercase letters), "I" (uppercase Roman numerals), and "i" (lowercase Roman numerals).
    • <ol type="A">
          <li>Item A</li>
          <li>Item B</li>
          <li>Item C</li>
      </ol>

    Output:-
    1. Item A
    2. Item B
    3. Item C

  3. Start Attribute:
  4. <ol start="5">
        <li>Item 5</li>
        <li>Item 6</li>
        <li>Item 7</li>
    </ol>
    
    Output:-
    1. Item 5
    2. Item 6
    3. Item 7

  5. Nested Ordered Lists:
    • Ordered lists can be nested inside other list items to create a hierarchical structure.
    <ol>
        <li>Main Item 1
            <ol>
                <li>Sub-item A</li>
                <li>Sub-item B</li>
            </ol>
        </li>
        <li>Main Item 2</li>
    </ol>

    Output:-
    1. Main Item 1
      1. Sub-item A
      2. Sub-item B
    2. Main Item 2
Example:
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Ordered List Example</title>
    </head>
    <body>
        <h1>Numbered List Example</h1>
        
        <ol type="I">
            <li>Item I</li>
            <li>Item II</li>
            <li>Item III</li>
        </ol>
    </body>
    </html>
      
Output:-

Numbered List Example

  1. Item I
  2. Item II
  3. Item III