<li>

Draft

Definition

The <li> HTML element is used to define an item in an ordered or unordered list. It represents a single item within a list and is typically used in conjunction with the <ul> (unordered list) or <ol> (ordered list) elements.

Here’s an example of how to use the <li> element in an unordered list:

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

In this example, the <li> element is used to define each item in the unordered list. The content inside each <li> element represents the text or content of the list item. The list items will be rendered with bullet points by default due to the <ul> element.

Here’s an example of how to use the <li> element in an ordered list:

<ol>
  <li>First item</li>
  <li>Second item</li>
  <li>Third item</li>
</ol>

In this example, the <li> element is used to define each item in the ordered list. The list items will be rendered with numbers or letters by default due to the <ol> element.

The <li> element can also be nested to create nested lists. For example:

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

In this example, a nested unordered list is created within the second list item.

Related posts