li

Defines an item in a list using HTML.
2 min read
Believemy logo

The <li> tag is used in HTML to define a list item in an ordered list (<ol>), an unordered list (<ul>), or a definition list (<dl>).

Warning

Each item in a list is always included in a <li> tag.

 

Structure and syntax of the <li> tag

Basic structure and syntax

Here is the basic syntax of the <li> tag:

HTML
<ul>
  <li>First item</li>
  <li>Second item</li>
  <li>Third item</li>
</ul>

The <li> tag must be used within an ordered list (<ol>) or unordered list (<ul>), to define an item in the list.

 

Usage example

Here is an example of using the <li> tag in an unordered list:

HTML
<ul>
  <li>Bread</li>
  <li>Cheese</li>
  <li>Wine</li>
</ul>

In this example, each item in the list is defined by a <li> tag within the <ul> tag.

 

Attributes

The <li> tag can accept generic attributes such as class, id, and style, but it does not have specific attributes.

 

Difference with other similar tags

  • <ul>: The <ul> tag is used to create an unordered list, in which each item is defined by a <li> tag.
  • <ol>: The <ol> tag is used to create an ordered list, in which each item is also defined by a <li> tag.
  • <dl>: The <dl> tag is used for a definition list, in which terms are defined by a <dt> tag and definitions by a <dd> tag.

 

Browser compatibility

The <li> tag is supported by all modern browsers.

BrowserCompatibility
ChromeYes
FirefoxYes
SafariYes
EdgeYes
Internet ExplorerYes

Related terms

Discover our hTML and CSS glossary

Browse the terms and definitions most commonly used in HTML and CSS development.

Share this article

Want to help us? Share this article on your networks or even better: on your site, in an article or in your newsletter.