Breaking

Thursday, May 9, 2019

HTML li Tag

Example

One ordered (<ol>) and one unordered (<ul>) HTML list:
<ol>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>

<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>
Try it Yourself »
More "Try it Yourself" examples below.

Definition and Usage

The <li> tag defines a list item.
The <li> tag is used in ordered lists(<ol>), unordered lists (<ul>), and in menu lists (<menu>).

Browser Support

Element
<li>YesYesYesYesYes

Differences Between HTML 4.01 and HTML5

The "type" attribute is NOT supported in HTML5.
The "value" attribute was deprecated in HTML 4.01, but IS supported in HTML5.


Tips and Notes

Tip: Use CSS to define the type of list.

Attributes

AttributeValueDescription
type1
A
a
I
i
disc
square
circle
Not supported in HTML5.Specifies which kind of bullet point will be used
valuenumberSpecifies the value of a list item. The following list items will increment from that number (only for <ol> lists)

Global Attributes

The <li> tag also supports the Global Attributes in HTML.

Event Attributes

The <li> tag also supports the Event Attributes in HTML.

Try it Yourself - Examples

A nested list
A list inside a list.
Another nested list
A more complicated nested list.

Related Pages

HTML tutorial: HTML Lists
HTML DOM reference: Li Object
CSS Tutorial: Styling Lists

Default CSS Settings

Most browsers will display the <li> element with the following default values:
li {
  display: list-item;
}

No comments:

Post a Comment