HTML-Lists

HTML-Lists

HTML-Lists

In HTML, there are three types of lists that can be used to organize and structure content:

  1. Unordered lists (<ul>): An unordered list is used to represent a list of items that do not have a specific order or sequence. The list items are preceded by bullet points by default. Here’s an example:
				
					<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>

				
			
  1. Ordered lists (<ol>): An ordered list is used to represent a list of items that have a specific order or sequence. The list items are preceded by numbers by default. Here’s an example:
				
					<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>

				
			
  1. Definition lists (<dl>): A definition list is used to represent a list of terms and their definitions. Each term is represented by a <dt> element, and each definition is represented by a <dd> Here’s an 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>

				
			

Lists can also be nested within each other, for example:

				
					<ul>
<li>Item 1</li>
<li>Item 2
<ul>
<li>Sub-item 1</li>
<li>Sub-item 2</li>
</ul>
</li>
<li>Item 3</li>
</ul>

				
			

In this example, the second list item contains a nested unordered list with two sub-items.

Lists can be styled using CSS, for example, to change the bullet points or numbering style, or to add custom backgrounds or borders to the list items.

Join To Get Our Newsletter
Spread the love