<li> Tag in HTML
The <li> tag in HTML represents a list item. It is used inside ordered (<ol>
) or unordered (<ul>
) lists to define individual items in the list. The <li>
tag can also be used within menu lists (<menu>
) or description lists (<dl>
) in HTML.
Key Points on <li> Tag:
- Used to define a list item inside ordered, unordered, or other types of lists.
- Each
<li>
element represents a single item in the list. - The
<li>
tag must be placed inside a<ul>
,<ol>
,<menu>
, or<dl>
tag. - Each list item can contain text, images, links, or other HTML elements.
Syntax of <li> Tag:
Syntax Example
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
Example of <li> Tag in HTML:
This example demonstrates how to use the <li>
tag in both ordered and unordered lists.
Code Example
<ul>
<li>Apples</li>
<li>Bananas</li>
<li>Cherries</li>
</ul>
<ol>
<li>First Item</li>
<li>Second Item</li>
<li>Third Item</li>
</ol>
Output
- Apples
- Bananas
- Cherries
Attributes of <li> Tag:
- value: In an ordered list, the
value
attribute specifies the starting number of the list item.
The <li>
tag is fundamental for creating lists in HTML, and it should always be used within a <ul>
, <ol>
, or <menu>
tag. The <li>
element supports various types of content, such as text, images, or links, making it a versatile tag for organizing information in a list format.