What are list tags in HTML?
In HTML, a list is a type of element used to represent a collection of items in a structured format. Lists are commonly used to organize and present information in a structured and easy-to-read manner.
There are three main types of lists in HTML:
- Ordered List (
<ol>
):
An ordered list is a list of items where each item is preceded by a number or letter to indicate its order. Ordered lists are typically used when the order of items is important or meaningful.
Example:
<ol>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ol>
Output:
Item 1
Item 2
Item 3
- Unordered List (
<ul>
):
An unordered list is a list of items where each item is preceded by a bullet point or other marker to indicate its presence in the list. Unordered lists are typically used when the order of items is not important.
Example:
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
Output:
Item 1
Item 2
Item 3
- Definition List (
<dl>
):
A definition list is a list of terms and their corresponding definitions. Each term is represented using a <dt>
(definition term) element, and each definition is represented using a <dd>
(definition description) element.
Example:
<dl>
<dt>Term 1</dt>
<dd>Definition 1</dd>
<dt>Term 2</dt>
<dd>Definition 2</dd>
<dt>Term 3</dt>
<dd>Definition 3</dd>
</dl>
Output:
Term 1
: Definition 1
Term 2
: Definition 2
Term 3
: Definition 3
These are the three main types of lists in HTML, each serving a specific purpose in organizing and presenting information on a webpage.