Lists in HTML

Definition

HTML lists are used to group related items in an ordered or unordered manner.

Types of Lists in HTML

1. Ordered List (<ol>)

Used when the order of items matters.

Syntax

<ol>
    <li>HTML</li>
    <li>CSS</li>
    <li>JavaScript</li>
</ol>

Output

2. Unordered List (<ul>)

Used when the order does not matter.

Syntax

<ul>
    <li>Python</li>
    <li>Java</li>
    <li>C</li>
</ul>

Output

3. Description List (<dl>)

Used to show terms and their descriptions.

Syntax

<dl>
    <dt>HTML</dt>
    <dd>Markup language for web pages</dd>
</dl>

4. Nested List

A list inside another list.

Example

<ul>
    <li>Frontend
        <ul>
            <li>HTML</li>
            <li>CSS</li>
        </ul>
    </li>
</ul>

Output

Important List Tags

TagUse
<ol>Ordered list
<ul>Unordered list
<li>List item
<dl>Description list
<dt>Term
<dd>Description