<li> : List Item element

Introduction

The <li> (list item) element in HTML is used to define individual items within ordered lists (<ol>) or unordered lists (<ul>). It is a container element that holds the content of each list item. Here’s how it is typically used:

Example with Unordered List (<ul>):

Output :

In this example, each <li> element represents an item in an unordered list.

Example with Ordered List (<ol>):

Output :

Here, each <li> element represents an item in an ordered list, where the order of items matters.

Nested Lists:

Lists can also be nested, where an <ul> or <ol> element is placed inside an <li> element to create a sublist:

In this example, “Main item 2” has a nested unordered list as a sublist.

The <li> element is a fundamental building block for creating lists in HTML, and it is essential for conveying structured information on a webpage. Lists can be styled using CSS to achieve various visual presentations, such as changing bullet points or numbering styles.

Leave a Comment