Lists are used to organize and present information in a structured manner. There are three types of lists in HTML:
Ordered Lists (<ol>
): Ordered lists are used when the order of items is important. Each list item is preceded by a number or another marker to indicate the sequence. The <ol>
element is used to define an ordered list, and each list item is represented by the <li>
(list item) element. Here's an example:
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
The above code will render as:
Unordered Lists (<ul>
): Unordered lists are used when the order of items doesn't matter. Each list item is typically displayed with a bullet point. The <ul>
element is used to define an unordered list, and each list item is represented by the <li>
element. Here's an example:
<ul>
<li>Red</li>
<li>Green</li>
<li>Blue</li>
</ul>
The above code will render as:
Definition Lists (<dl>
): Definition lists are used to define terms and their corresponding descriptions. The <dl>
element is used to define a definition list, the <dt>
element represents the term, and the <dd>
element represents the definition. Here's an example:
<dl>
<dt>HTML</dt>
<dd>Hypertext Markup Language</dd>
<dt>CSS</dt>
<dd>Cascading Style Sheets</dd>
</dl>
The above code will render as:
HTML
CSS
Thank You.