HTML5 <li> Tag

The HTML <li> tag is used to represent an item in a list. It must be contained in a parent element: an ordered list (<ol>), an unordered list (<ul>), or a menu (<menu>). In case of menus and unordered lists, list items are usually displayed using bullet points. In case of ordered lists, they are usually displayed with an ascending counter on the left, such as a number or letter.

The only content permitted inside this element is Flow content. For this element, the end tag can be omitted if the list item is immediately followed by another <li> element, or if there is no more content in its parent element. The parent of the <li> tag can be an <ul>, <ol>, or <menu> element. Though not a conforming usage, the obsolete <dir> can also be a parent.

The following style is applied to this element by default:

li {
  display: list-item;
  text-align: -webkit-match-parent;
}

Here is an example of using this tag:

<ol>
  <li>Planet Earth II</li>
  <li>Band of Brothers</li>
  <li>Game of Thrones</li>
  <li>Breaking Bad</li>
</ol>

<ol>
  <li value="10">Sherlock</li>
  <li>The World at War</li>
  <li>Life</li>
  <li>Avatar: The Last Airbender</li>
</ol>

<ul>
  <li>Apple</li>
  <li>Mango</li>
  <li>Banana</li>
</ul>

Attributes

value

This integer attribute indicates the current ordinal value of the list item as defined by the <ol> element. The only allowed value for this attribute is a number, even if the list is displayed with Roman numerals or letters. List items that follow this one continue numbering from the value set. The value attribute has no meaning for unordered lists (<ul>) or for menus (<menu>).

This attribute was deprecated in HTML4, but reintroduced in HTML5.

type

This character attribute indicates the numbering type:

  • a: lowercase letters
  • A: uppercase letters
  • i: lowercase Roman numerals
  • I: uppercase Roman numerals
  • 1: numbers

This type overrides the one used by its parent <ol> element, if any. This attribute has been deprecated. Use the CSS list-style-type property instead.

Examples

See the Pen HTML li Tag by Tutorialio (@tutorialio) on CodePen.

Further Reading

  1. Read more about the HTML <li> element on MDN.
  2. You can also read the HTML <li> tag reference on W3C.

Reader Comments

1. You can register or login to post a comment. Asking readers to register improves the quality of discussion.

2. As a registered user, you will also get to access features like choosing between a light and dark theme or anything else that we might implement in future.

Follow Us For Updates

FacebookTwitterGoogle+
Go To Top