HTML lists allow us to organize and display items in a structured format. There are three main types of lists:
1️⃣ Ordered List (<ol>
) → Numbered list
2️⃣ Unordered List (<ul>
) → Bulleted list
3️⃣ Description List (<dl>
) → Term and description list
<ol>
)An ordered list displays items in a specific sequence using numbers or letters.
<ol>
<li>Step 1: Preheat the oven</li>
<li>Step 2: Mix ingredients</li>
<li>Step 3: Bake the cake</li>
</ol>
✔ Each <li>
(list item) represents one step.
✔ The browser automatically numbers the items.
You can customize the numbering style using the type
attribute:
<ol type="A"> <!-- Uses uppercase letters -->
<li>Item 1</li>
<li>Item 2</li>
</ol>
Type Value | Numbering Style |
---|---|
1 (default) |
1, 2, 3, 4... |
A |
A, B, C, D... |
a |
a, b, c, d... |
I |
I, II, III, IV... |
i |
i, ii, iii, iv... |
<ul>
)An unordered list displays items with bullets instead of numbers.
<ul>
<li>Apples</li>
<li>Bananas</li>
<li>Cherries</li>
</ul>
✔ Default bullets are solid circles.
You can change the bullet style using CSS:
ul {
list-style-type: square; /* Options: disc, circle, square */
}
Value | Bullet Style |
---|---|
disc (default) |
● Bullet |
circle |
○ Hollow Circle |
square |
■ Square |
<dl>
)A description list is used to define terms and descriptions.
<dl>
<dt>HTML</dt>
<dd>HyperText Markup Language</dd>
<dt>CSS</dt>
<dd>Cascading Style Sheets</dd>
</dl>
✔ <dt>
→ Defines the term.
✔ <dd>
→ Defines the description.
You can nest lists inside each other.
<ul>
<li>Fruits
<ul>
<li>Apple</li>
<li>Banana</li>
</ul>
</li>
<li>Vegetables
<ul>
<li>Carrot</li>
<li>Spinach</li>
</ul>
</li>
</ul>
✔ This creates a list inside a list for better organization.
List Type | Tag | Usage |
---|---|---|
Ordered List | <ol> |
Numbered steps or rankings |
Unordered List | <ul> |
Bullet points for unordered items |
Description List | <dl> |
Term and description pairs |
Nested List | <ul> / <ol> inside another list |
Hierarchical data |
✅ Use <ol>
for sequential steps.
✅ Use <ul>
for unordered information.
✅ Use <dl>
for definitions or explanations.
✅ Use CSS to style lists for better appearance.