HTML Tutorial

HTML Tag: <li>

Usage of <li>

The <li> tag, short for "list item," is used to define individual items within a list. It is commonly used inside <ul> (unordered list) or <ol> (ordered list) elements.

Attributes of <li>

The <li> tag can have the following attributes:

  • value: Specifies the numerical value of the list item, used for <ol> only.
  • type: Defines the type of marker used for <ul> only (e.g., "circle", "square").

Examples with <li>

<ul>
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ul>

<ol>
  <li value="1">First Item</li>
  <li value="2">Second Item</li>
  <li value="3">Third Item</li>
</ol>

Exploring the <li> Tag: A Simple HTML Example

HTML Code:

<!DOCTYPE html>
<html>
<body>

<h1>My List</h1>
<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Juice</li>
</ul>

</body>
</html>

Result:

This code will create an HTML document with a heading "My List" and an unordered list containing three items: "Coffee", "Tea", and "Juice".

Key Points:

  • The <ul> tag defines the list.
  • Each <li> tag represents an individual item in the list.
  • No attributes are used on the <li> tags in this example.