Loading...
Loading...
00:00:00

<ul>, <ol> and <li> tags in HTML5

The ul (unordered list), ol (ordered list), and li (list item) tags are used to create lists in HTML5. These tags are semantic elements, meaning they provide information about the content they contain, rather than just specifying its appearance.

ul tag

The ul tag is used to create an unordered list, which is a list of items that are marked with bullet points. Here's an example of how the ul tag might be used in an HTML document:

<ul>
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ul>

ol tag

The ol tag is used to create an ordered list, which is a list of items that are numbered. Here's an example of how the ol tag might be used in an HTML document:

<ol>
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ol>

The li tag is used to define each individual item in a list. It must be contained within either an ul or an ol tag. Here's an example of how the li tag might be used in an HTML document:

<ul>
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ul>

In both ordered and unordered lists, the default appearance of the bullet points or numbers can be changed using CSS. For example, you might change the default bullet points to images, or change the color of the numbers.

Lists are often used to organize content into logical groups, and to create hierarchical structures. For example, you might use an ordered list to create a step-by-step guide, or an unordered list to create a list of items that don't have a particular order.

In addition to organizing content, lists can also be used to create navigation menus. For example, you might create a list of links to different pages on your website, and use CSS to style the list so that it appears as a navigation menu.

Nested list

Lists can also be nested within each other to create more complex structures. For example, you might use an ordered list to create a list of steps, and within each step, you might use an unordered list to list the items required for that step.

<ol>
  <li>Step 1
    <ul>
      <li>Item 1</li>
      <li>Item 2</li>
      <li>Item 3</li>
    </ul>
  </li>
  <li>Step 2
    <ul>
      <li>Item 1</li>
      <li>Item 2</li>
      <li>Item 3</li>
    </ul>
  </li>
  <li>Step 3
    <ul>
      <li>Item 1</li>
      <li>Item 2</li>
      <li>Item 3</li>
    </ul>
  </li>
</ol>

In addition to organizing content, nested lists can also be used to create multi-level navigation menus. For example, you might create a list of links to different sections of your website, and within each section.