In this tutorial, we will learn about the HTML List, as well as its kinds and several approaches to apply them using an example.
A list is a collection of small bits of connected information that is used to present data or other information in web pages in either an ordered or unordered fashion. For example, in order to purchase products, we must first create a list that may be either sorted or unordered, allowing us to arrange the data and easily locate the item. Please see the HTML
<li> type Attribute article for more information on the many sorts of attributes that may be used with sorted and unordered lists.
Tags that are supported: These tags are used in HTML listings.
Unordered list in HTML
Attribute: This tag has two characteristics, which are as follows:
- compact: It will make the list shorter.
- type: This parameter indicates the type of marker that will be used in the list.
Note: HTML5 does not recognize the
There are several list item identifiers in an HTML unordered list:
HTML Ordered List
- compact: It specifies whether or not the list should be compressed (the compact property is not supported by HTML5). Instead, use CSS.) .
- reversed: It specifies that the order shall be descending.
- start: This specifies where the order will begin, whether it be a number or an alphabet.
- type: It specifies whether the order in your list should be numeric, alphabetic, or roman numerals (1, A, a, I, and I).
HTML Description List
A description set is a list of words that each have a description. The description list is defined by the
<dl> tag, the term name is defined by the
<dt> tag, and each term is described by the
<dd> tag. For further information, see the article How to Add a Description List to an Element Using HTML.
<ul> <li>List item 1</li> <li>List item 2 <ul> <li>Nested list item 1</li> <li>Nested list item 2</li> </ul> </li> <li>List item 3</li> </ul>
This will create an unordered list with three items, where the second item has a nested unordered list with two items. You can also create nested ordered lists using the same approach but with the
To add links to list items in HTML, you can use the anchor tag
<a> and wrap it around the list item content. Here's an example:
<ul> <li><a href="https://webtutor.dev">Link 1</a></li> <li><a href="https://webtutor.dev">Link 2</a></li> <li><a href="https://webtutor.dev">Link 3</a></li> </ul>
In this example, each list item is wrapped in an anchor tag, and the href attribute specifies the URL that the link should point to. When the user clicks on the link, they will be taken to the specified URL.