totn HTML

HTML: <li> tag

This HTML tutorial explains how to use the HTML element called the <li> tag with syntax and examples.

Description

The HTML <li> tag defines a list item in <ol>, <ul> or <menu> in the HTML document. This tag is also commonly referred to as the <li> element.

Syntax

In HTML, the syntax for the <li> tag within <ul> tag is: (unordered list)

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

Sample Output



In HTML, the syntax for the <li> tag within <ol> tag is: (ordered list)

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


In HTML, the syntax for the <li> tag within <menu> tag is:

<body>
<menu type="toolbar">
  <li>
    <menu label="File">
      <button type="button" onclick="new()">New</button>
      <button type="button" onclick="save()">Save</button>
    </menu>
  </li>
  <li>
    <menu label="Edit">
      <button type="button" onclick="copy()">Copy</button>
      <button type="button" onclick="paste()">Paste</button>
    </menu>
  </li>
</menu>
</body>

Attributes

In addition to the Global Attributes, the following is a list of attributes that are specific to the <li> tag:

Attribute Description HTML Compatibility
value Integer value indicating the current ordinal value of the item only in <ol> list Deprecated in HTML 4.01, Reintroduced in HTML5
type Character value indicating numbering style. It can be any of the following values:
a - means lowercase
A - means uppercase
i - means lowercase Roman numerals
I - means uppercase Roman numerals
1 - means numbers
Deprecated, use CSS

Note

Browser Compatibility

The <li> tag is compatible with the following browsers:

  • Chrome
  • Android
  • Firefox (Gecko)
  • Firefox Mobile (Gecko)
  • Internet Explorer (IE)
  • Edge Mobile
  • Opera
  • Opera Mobile
  • Safari (WebKit)
  • Safari Mobile

Example

We will discuss the <li> tag below, exploring examples of how to use the <li> tag in HTML5, HTML 4.01 Transitional, XHTML 1.0 Transitional, XHTML 1.0 Strict, and XHTML 1.1.