HTML <li> Tag

The HTML <li> tag represents a list item in ordered and unordered lists.

The <li> tag is placed inside either a <ol> tag or a <ul> to represent each individual item within that list. It can also be used with the <menu> tag for HTML 5.1 and HTML Living Standard documents.


The <li> tag is written as <li></li> with the list item inserted between the start and end tags. The element must be placed inside either a <ol> tag or a <ul> tag to provide each individual list item within those elements.

The <li> tag can also be used inside the <menu> element (only when the element is in the toolbar state), however, that element is not supported by the W3C HTML5 specification - it is currently only supported by the HTML 5.1 specification and the WHATWG HTML Living Standard.

Like this:


Unordered List

Here's an example of using the <li> inside the <ul> tag to create an unordered list.

Ordered List

Here's an example of using the <li> inside the <ol> tag to create an ordered list.

The value Attribute

You can use the value attribute to specify a number for a list item. Any subesquent list items increment their value from that initial value (unless you override it with a new value).

Note that you can only use the value attribute when using the <ol> element.

Also note that the ordinal value of the value attribute must be a valid integer.

Applying Styles

You can use the CSS list-style, list-style-image, list-style-position, and list-style-type properties to change the styles of the <li> elements.

Although you can apply these properties directly to the <li> element, they are usually applied to the parent element (which is then cascaded down to the <li> element).

Here are some examples.

Roman Numerals

This example uses the list-style-type property to specify roman numerals.

Square Bullets

This example uses the list-style-type property to specify square bullets for each list item within an unordered list.


You can replace the bullet points with an image using the list-style-image property.

Position of List Item

This example uses the list-style-position property to specify the position of the list items.

The list-style Property

The list-style property is a shortcut property. It allows you to apply multiple properties to your list items.



Attributes can be added to an HTML element to provide more information about how the element should appear or behave.

The <li> element accepts the following attributes.

valueSpecifies the value of the list item. The value must be a number. Can only be used if the list is an ordered list (i.e. <ol>).

Global Attributes

The following attributes are standard across all HTML elements. Therefore, you can use these attributes with the <li> tag , as well as with all other HTML tags.

For a full explanation of these attributes, see HTML 5 global attributes.

Event Handlers

Event handler content attributes enable you to invoke a script from within your HTML. The script is invoked when a certain "event" occurs. Each event handler content attribute deals with a different event.

Most event handler content attributes can be used on all HTML elements, but some event handlers have specific rules around when they can be used and which elements they are applicable to.

For more detail, see HTML event handler content attributes.