<li>
<li> Tag
The <li> element is used to represent an item within a list. It must be enclosed within an ordered list <ol>, an unordered list <ul>, or a menu <menu>. In unordered lists and menus, items are displayed with bullet points, whereas ordered lists use numbers or letters for enumeration.
Syntax
<!-- Unordered list -->
<ul>
<li>List item 1</li>
<li>List item 2</li>
<li>List item 3</li>
</ul>
<!-- Ordered list -->
<ol>
<li>List item 1</li>
<li>List item 2</li>
<li>List item 3</li>
</ol>
Attributes
value
The value attribute in <li> specifies the starting point for an item in an ordered list <ol>. Subsequent items in the list will increment from this number. This attribute is not applicable to unordered lists <ul> or menus <menu>.
type
The type attribute determines the numbering format for an ordered list:
a: lowercase lettersA: uppercase lettersi: lowercase Roman numeralsI: uppercase Roman numerals1: standard numerical order
Examples
For additional examples, refer to the <ol> and <ul> documentation.
Ordered List
- First item
- Second item
- Third item
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
Unordered List
- First item
- Second item
- Third item
<ul>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ul>
Conclusion
The <li> tag is fundamental for creating list items within ordered lists <ol>, unordered lists <ul>, or menus <menu>. It allows for easy organization of content, with customization options like the value and type attributes for ordered lists.
<dd>
The HTML <dd> element represents a description or value linked to a term in a <dl> (description list), commonly used for detailed information or explanations.
<dir>
The HTML <dir> element, which is now obsolete, was intended for creating a directory list of items with specific styling. CSS is recommended for this purpose now.