DEV Community

Cover image for Lists - HTML
Melina Caroline Bernard
Melina Caroline Bernard

Posted on

Lists - HTML

•List items are container tags.

•A list consists of list items <li>

•There are 2 types of lists

1.Ordered lists <ol> -
~These show with numbers.

~You can use these when the points have a certain order.

For example👇🏻

<ol>
<li> Coffee </li>
<li> Tea </li>
<li> Milk </li>;
</ol>

Enter fullscreen mode Exit fullscreen mode

Output👇🏻

  1. Coffee
  2. Tea
  3. Milk

2.Unordered lists <ul>
~They are shown with bullet points.

~You can use these when the order of the items is not important

Example 👇🏻

<ul>
<li> Coffee </li>
<li> Tea </li>
<li> Milk </li>;
</ul>
Enter fullscreen mode Exit fullscreen mode

Output

•Coffee
•Tea
• Milk

•A list can contain any number of items

• A list can be nested inside another

• (use indentation to make your code look clean when you prefer nesting)

<ul>
 <li>Coffee</li>
 
 <li>Tea (Varieties) 
    *<ul>
      <li>Green Tea</li>
      <li>Black Tea</li>
    </ul>*
 </li>
 <li>Milk</li>
</ul>

Enter fullscreen mode Exit fullscreen mode

💡Quick Tip

Each < li > tags are presented in new lines automatically

Example👇🏻

<ol>
<li>Item1</li><li>Item2</li>
<li>Item3</li>
<\ol>
Enter fullscreen mode Exit fullscreen mode

Output👇🏻

  1. Item1
  2. Item2
  3. Item3

Top comments (0)