Skip to: content, navigation

by Ian Lloyd

li (HTML element)

Spec
Depr. Empty Version
No No HTML 2
Browser support full matrix
IE5.5+ FF1+ Saf1.3+ Op9.2+
Full Full Full Full

Example

Here’s the li element in action, being used within a ol element:

<ol>
  <li>Remove the outer casing by pushing the plastic rivets
    through.</li>
  <li>Disconnect the main power harness from the inner unit
    (unclip).</li>
  <li>Remove connection to the glow plug.</li>
  <li>Extract unit, keeping upright at all times.</li>
</ol>
Type
block-level element
Contains
block-level element, inline elements
Contained by
ol, ul, dir, menu

Description

The li element defines an individual list item and can only appear inside the handful of list-related elements detailed above. Each list item is represented by a bullet (for unordered lists, defined by the ul element) or a number or letter (in the case of ordered lists, defined by the ol element).

The example above shows the li as it’s used in an ordered list (ol), but it could be applied identically inside an unordered list (ul):

<ul>
  <li>Eggs</li>
  <li>Cheese</li>
  <li>Milk</li>
  <li>Papadums</li>
  <li>Tickle-me Elmo</li>
  <li>Dr Who Remote Control Dalek</li>
</ul>

The two types of list items would render as shown in Figure 1.

Figure 1. An ordered list followed by an unordered list An ordered list followed by an unordered list

List items may also appear inside dir and menu elements, although it should be noted that both dir and menu are now deprecated and should no longer be used.

Use This For …

A list item will usually—but not always—contain text, along with some formatting (phrase) elements. However, an li can contain block-level elements, typically divs, nested ul or ol elements, and p elements.

Note that if the li element is contained inside either of the (now deprecated) dir or menu elements, it cannot contain block-level elements.

Compatibility

IE5.5Full
6.0Full
7.0Full
Firefox1.0Full
1.5Full
2.0Full
Safari1.3Full
2.0Full
3.0Full
Opera9.2Full
9.5Full

Every browser listed supports this element type.

In this Section

User-contributed notes

There are no comments yet.

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters