li (HTML element)
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.
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
| IE | 5.5 | Full |
|---|---|---|
| 6.0 | Full | |
| 7.0 | Full | |
| Firefox | 1.0 | Full |
| 1.5 | Full | |
| 2.0 | Full | |
| Safari | 1.3 | Full |
| 2.0 | Full | |
| 3.0 | Full | |
| Opera | 9.2 | Full |
| 9.5 | Full |
Every browser listed supports this element type.
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.

