HTML Lists:
HTML provides three types of lists to organize and structure content on a web page. Lists are essential for presenting information in a clear and hierarchical manner.
The three main types of lists in HTML are:
- Unordered Lists (<ul>):
- Unordered lists are created using the <ul> element.
- List items within an unordered list are defined with the <li> (list item) element.
- Unordered lists typically display items with bullet points by default.
- Item 1
- Item 2
- Item 3
- Ordered Lists (<ol>):
- Ordered lists are created using the <ol> element.
- List items within an ordered list are defined with the <li> element.
- Ordered lists typically display items with numbers or letters by default.
- First Item
- Second Item
- Third Item
- Definition Lists (<dl>):
- Definition lists are created using the <dl> element.
- Each item in a definition list consists of a term (<dt> - definition term) and its definition (<dd> - definition description).
- Definition lists are suitable for glossaries or explanations.
- Item A
- Item B
- Item C
Example:
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
Output:-
Example:
<ol>
<li>First Item</li>
<li>Second Item</li>
<li>Third Item</li>
</ol>
Output:-
Example:
<ol>
<li>First Item</li>
<li>Second Item</li>
<li>Third Item</li>
</ol>
Output:-
- type Attribute (for <ol>):
- The type attribute can be used to specify the type of numbering or bullet points in an ordered list.
- Values include "1" (numbers), "A" (uppercase letters), "a" (lowercase letters), "I" (uppercase Roman numerals), and "i" (lowercase Roman numerals).
- Item A
- Item B
- Item C
- start Attribute (for <ol>):
- The start attribute specifies the starting value for the numbering in an ordered list.
- Item 5
- Item 6
- Item 7
<ol type="A">
<li>Item A</li>
<li>Item B</li>
<li>Item C</li>
</ol>
Output:-
Example:
<ol start="5">
<li>Item 5</li>
<li>Item 6</li>
<li>Item 7</li>
</ol>
Output:-
Understanding and utilizing these list types in HTML allows for effective organization and presentation of content, contributing to a well-structured and user-friendly web page.