HTML Lists

Organize related information with unordered, ordered, and description lists.

When creating a webpage, you often need to display information in an organized way. For example, you may want to show a shopping list, website menu, course topics, or step-by-step instructions.

HTML lists group related items together. This makes web pages easier to read, scan, and understand.

Types of HTML Lists

There are three main types of lists in HTML:

  • Unordered lists
  • Ordered lists
  • Description lists

Each type has a different purpose. Choosing the right list type makes your content clearer.

Why Use HTML Lists?

Lists are used to organize information into separate items. They help users quickly scan content instead of reading long paragraphs.

Some common uses of HTML lists include:

  • Navigation menus
  • Shopping lists
  • Course topics
  • Product features
  • Instructions and tutorials
  • FAQs

Unordered List

An unordered list displays items with bullet points. Use it when the order of the items does not matter.

The ul tag creates an unordered list. Each item is written inside an li tag.

HTML
<ul>
    <li>HTML</li>
    <li>CSS</li>
    <li>JavaScript</li>
</ul>

Output:

devbrainbox.local/output
  • HTML
  • CSS
  • JavaScript

When to Use an Unordered List

Use an unordered list when:

  • The sequence is not important.
  • You want to display options or categories.
  • You are listing features or services.

Changing the Bullet Style

Older HTML used the type attribute to change bullet styles, but this is obsolete in HTML5.

HTML
<ul type="square">
    <li>HTML</li>
    <li>CSS</li>
    <li>JavaScript</li>
</ul>

Modern websites should use CSS to change list styles because CSS keeps design separate from HTML content.

HTML
<ul class="languages">
    <li>HTML</li>
    <li>CSS</li>
    <li>JavaScript</li>
</ul>
CSS
.languages {
    list-style-type: square;
}

Common CSS values include:

  • disc for a filled circle
  • circle for a hollow circle
  • square for a square bullet
  • none for no bullet

Ordered List

An ordered list displays items with numbers or letters. Use it when the order of the items is important.

The ol tag creates an ordered list.

HTML
<ol>
    <li>Open your browser.</li>
    <li>Create a new HTML file.</li>
    <li>Write your HTML code.</li>
    <li>Save the file.</li>
</ol>

Output:

devbrainbox.local/output
  1. Open your browser.
  2. Create a new HTML file.
  3. Write your HTML code.
  4. Save the file.

Changing the Number Style

The type attribute changes how ordered list numbers appear.

HTML
<ol type="A">
    <li>Chapter One</li>
    <li>Chapter Two</li>
    <li>Chapter Three</li>
</ol>

Output:

devbrainbox.local/output
  1. Chapter One
  2. Chapter Two
  3. Chapter Three

Common ordered list type values are:

  • 1 for numbers
  • A for uppercase letters
  • a for lowercase letters
  • I for uppercase Roman numbers
  • i for lowercase Roman numbers

Starting from a Different Number

You can start an ordered list from any number using the start attribute.

HTML
<ol start="5">
    <li>Chapter Five</li>
    <li>Chapter Six</li>
    <li>Chapter Seven</li>
</ol>

Output:

devbrainbox.local/output
  1. Chapter Five
  2. Chapter Six
  3. Chapter Seven

Reversing an Ordered List

The reversed attribute displays an ordered list in reverse order.

HTML
<ol reversed>
    <li>Third Step</li>
    <li>Second Step</li>
    <li>First Step</li>
</ol>

Output:

devbrainbox.local/output
  1. Third Step
  2. Second Step
  3. First Step

Description List

A description list is used to display terms with their descriptions. It is useful for definitions, FAQs, and simple explanations.

Description lists use three tags:

  • dl for the description list
  • dt for the term
  • dd for the description
HTML
<dl>
    <dt>HTML</dt>
    <dd>Used to create the structure of web pages.</dd>

    <dt>CSS</dt>
    <dd>Used to style web pages.</dd>

    <dt>JavaScript</dt>
    <dd>Used to add interactivity to websites.</dd>
</dl>

Nested Lists

A nested list is a list placed inside another list. It helps organize categories and subcategories.

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

Output:

devbrainbox.local/output
  • Frontend
    • HTML
    • CSS
    • JavaScript
  • Backend

Best Practices

When creating HTML lists, follow these simple rules:

  • Choose the correct list type for your content.
  • Use unordered lists when order does not matter.
  • Use ordered lists for steps, rankings, or instructions.
  • Use description lists for terms and explanations.
  • Keep list items short and meaningful.
  • Use CSS to style lists.
  • Avoid deeply nested lists unless they are really needed.

Key Takeaways

  • HTML lists help organize information clearly.
  • Use ul for bullet lists where order does not matter.
  • Use ol for numbered lists where order is important.
  • Use dl for terms and their descriptions.
  • The li tag creates each item in unordered and ordered lists.
  • Nested lists help show categories and subcategories.
  • Use CSS when you want to change list styles.