HTML
  • Tag (List Item) Tutorial
  • HTML provides the <li> tag to create a list item. The <li> tag can be used to create ordered, unordered and menu lists. These lists can be created with the <ol> (Ordered list), <ul> (Unordered list) and <menu> (Menu list) tags. Every item in these lists can be created using the <li> tag. The <li> tag can also be used to create child items too. The <li> tag is supported by all major browsers like Google Chrome, Microsoft Edge, Mozilla Firefox, Opera, etc.

    Create Ordered List

    We can start with a simple example by creating an ordered list. We use the <ol> tag to create ordered list and <li> to create every list items.

    <html>
    <body>
    
    <h1>The Ordered List</h1>
    
    <ol>
       <li>Ankara</li>
       <li>İstanbul</li>
       <li>İzmir</li>
    </ol>
    
    </body>
    </html>
    
    Create Ordered List

    Create Unordered List

    The <li> tag can be also used to add items inside the unordered list. The <ul> tag is used to create an unordered list.

    <html>
    <body>
    
    <h1>The Unordered List</h1>
    
    <ul>
       <li>Ankara</li>
       <li>İstanbul</li>
       <li>İzmir</li>
    </ul>
    
    </body>
    </html>
    Create Unordered List

    Create Nested List

    The <li> tag can be used to create a nested list where a list is an item of another or parent list.

    <html>
    <body>
    
    <h1>The Nested List</h1>
    
    <ul>
       <li>Ankara</li>
          <ul>
             <li>Çankaya</li>
             <li>Yenimahalle</li>
          </ul>
       <li>İstanbul</li>
       <li>İzmir</li>
    </ul>
    
    </body>
    </html>
    Create Nested List

    Set List Item Number

    When creating an ordered list the numbers start from 1 by default. But we can set different numbers to start by using the value attribute of the <li> tag. In the following example we set the list item number as 10 and this is incremented in every item 1by1 .

    <html>
    <body>
    
    <h1>The Ordered List</h1>
    
    <ol>
       <li value=10>Ankara</li>
       <li>İstanbul</li>
       <li>İzmir</li>
    </ol>
    
    </body>
    </html>
    Set List Item Number

    Leave a Comment