HTML lists are an essential feature for organizing content in a structured and readable format. They are used to display information as a collection of related items.
There are three main types of HTML lists:
<ol>
)<ul>
)<dl>
)
Ordered lists use the <ol>
tag to create a list of items where the order matters. Items are automatically numbered.
<ol>
<li>Step 1: Learn HTML</li>
<li>Step 2: Practice CSS</li>
<li>Step 3: Master JavaScript</li>
</ol>
Output:
a
, A
, i
, I
, 1
).
<ol type="I" start="3">
<li>Item 3</li>
<li>Item 4</li>
</ol>
Unordered lists use the <ul>
tag to create a list of items where the order does not matter. Items are typically marked with bullets.
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
Output:
You can change the bullet style using the list-style-type
property in CSS:
ul {
list-style-type: square;
}
Definition lists use the <dl>
, <dt>
, and <dd>
tags to create a list of terms and their definitions.
<dl>
<dt>HTML</dt>
<dd>A markup language for creating web pages.</dd>
<dt>CSS</dt>
<dd>A style sheet language for designing web pages.</dd>
</dl>
Output:
You can nest lists to create more complex structures:
<ul>
<li>Frontend
<ul>
<li>HTML</li>
<li>CSS</li>
</ul>
</li>
<li>Backend
<ul>
<li>Node.js</li>
<li>PHP</li>
</ul>
</li>
</ul>
Output:
HTML List Tags are essential for organizing content into structured lists. They are primarily used to create ordered, unordered, or definition lists, making it easier for users to read and understand information.
The key list tags in HTML are:
<ul>
- Creates an unordered list.<ol>
- Creates an ordered list.<li>
- Defines each item in a list.<dl>
- Creates a definition list.<dt>
- Defines a term in a definition list.<dd>
- Defines a description in a definition list.HTML allows you to nest lists to create a hierarchy. For example:
<ul>
<li>Frontend
<ul>
<li>HTML</li>
<li>CSS</li>
</ul>
</li>
<li>Backend
<ul>
<li>Node.js</li>
<li>Python</li>
</ul>
</li>
</ul>
Output: