Lists in HTML
? Lists in HTML
HTML provides different types of lists to organize content in a structured way.
Types of Lists
1. Ordered List (<ol>)
Displays items in a numbered sequence.
<ol> <li>First item</li> <li>Second item</li> <li>Third item</li></ol>Output:
First item
Second item
Third item
2. Unordered List (<ul>)
Displays items with bullet points.
<ul> <li>Apples</li> <li>Bananas</li> <li>Oranges</li></ul>Output:
Apples
Bananas
Oranges
3. Description List (<dl>)
Used for terms and their descriptions.
<dl> <dt>HTML</dt> <dd>HyperText Markup Language</dd> <dt>CSS</dt> <dd>Cascading Style Sheets</dd></dl>Output:
HTML
HyperText Markup LanguageCSS
Cascading Style Sheets
Nesting Lists
Lists can be nested inside one another.
<ul> <li>Fruits <ul> <li>Apple</li> <li>Banana</li> </ul> </li> <li>Vegetables <ul> <li>Carrot</li> <li>Broccoli</li> </ul> </li></ul>Summary
| Tag | Purpose |
|---|---|
<ol> | Ordered (numbered) list |
<ul> | Unordered (bulleted) list |
<li> | List item (used inside <ol> or <ul>) |
<dl> | Description list |
<dt> | Term in description list |
<dd> | Description of term |
Need examples on styling lists or interactive lists?