html list
html list
A list is a collection of related items grouped together in HTML. Lists help organize content,
making it easy to read and understand. HTML provides three main types of lists:
An ordered list is used when the sequence of items is important. The list items (<li>) are
numbered automatically.
Syntax:
<ol>
<li>Wake up early</li>
<li>Exercise</li>
<li>Have breakfast</li>
<li>Start work</li>
</ol>
Output:
1. Wake up early
2. Exercise
3. Have breakfast
4. Start work
You can change the numbering style using the type attribute:
| Type | Description | |----------|---------------| | type=”1” | Default numbering (1, 2, 3…) | |
type=”A” | Uppercase letters (A, B, C…) | | type=”a” | Lowercase letters (a, b, c…) | | type=”I” |
Uppercase Roman numerals (I, II, III…) | | type=”I” | Lowercase Roman numerals (I, ii, iii…) |
<ol type=”I”>
<li>Introduction</li>
<li>Body</li>
<li>Conclusion</li>
</ol>
Output:
I. Introduction
II. Body
III. Conclusion
An unordered list is used when the order of items does not matter. Items are displayed with
bullet points.
Syntax:
<ul>
<li>Apple</li>
<li>Banana</li>
<li>Mango</li>
<li>Orange</li>
</ul>
Output:
Apple
Banana
Mango
Orange
You can change the bullet style using the type attribute:
<li>Pen</li>
<li>Notebook</li>
<li>Eraser</li>
</ul>
Output:
■ Pen
■ Notebook
■ Eraser
A definition list is used to define terms and their descriptions. It consists of:
Syntax:
<dl>
<dt>HTML</dt>
<dt>CSS</dt>
</dl>
Output:
HTML
CSS
<ul>
<li>Fruits
<ul>
<li>Apple</li>
<li>Mango</li>
</ul>
</li>
<li>Vegetables
<ul>
<li>Carrot</li>
<li>Spinach</li>
</ul>
</li>
</ul>
Output:
Fruits
Apple
Mango
Vegetables
Carrot
Spinach
Answer:
Q3: How can you create an ordered list with Roman numerals?
Example:
<ol type=”I”>
<li>Introduction</li>
<li>Content</li>
<li>Conclusion</li>
</ol>
Answer:
Example:
<ul>
<li>Languages
<ul>
<li>HTML</li>
<li>CSS</li>
</ul>
</li>
</ul>
Output:
Languages
HTML
CSS