HTML Lists
HTML provides multiple ways to create lists, displaying information in a clear, structured form. The three main list types are:
- Unordered List: Items are marked with bullet points (like circles or squares).
- Ordered List: Items are marked with numbers or letters.
- Description List: Used to display terms and their definitions.
1. Unordered List <ul>
Unordered lists are created with the <ul> (Unordered List) tag. Each item in the list is defined by the <li> (List Item) tag.
Browsers default to displaying a solid circle bullet before each list item.
You can use CSS's list-style-type property to change the bullet style, e.g., disc (default), circle, square, or none.
2. Ordered List <ol>
Ordered lists are created with the <ol> (Ordered List) tag. Each item is also defined by the <li> tag.
Browsers default to displaying incrementing numbers before each list item.
The <ol> tag has some useful attributes:
type: Changes the numbering type.1(default): Numbers (1, 2, 3)A: Uppercase letters (A, B, C)a: Lowercase letters (a, b, c)I: Uppercase Roman numerals (I, II, III)i: Lowercase Roman numerals (i, ii, iii)
start: Specifies the starting value for numbering.
3. Description List <dl>
Description lists are special lists used to display a series of terms and their explanations. They consist of three tags:
<dl>(Description List): The container for the list.<dt>(Description Term): Defines a term or name.<dd>(Description Details): Describes or explains the term.
Browsers typically add indentation to <dd> content.
Nested Lists
Any type of list can be nested within another list to create more complex hierarchical structures.