HTML Lists Explained - Organize Content with ul and ol

Lists are among the most used HTML elements in real websites. Your site navigation? A list. Steps in a tutorial? A list. Product features? A list. HTML provides three types that cover all cases.

Type 1: Unordered List - <ul>

<ul> is short for Unordered List. Use it when order does not matter - shopping lists, feature lists, multiple options. The browser shows a bullet (.) before each item by default.

<ul>
    <li>HTML - Build the page structure</li>
    <li>CSS - Style layout and colors</li>
    <li>JavaScript - Add interactivity</li>
</ul>

Result in the browser:

  • HTML - Build the page structure
  • CSS - Style layout and colors
  • JavaScript - Add interactivity

<li> is short for List Item - each item in the list. It is used inside <ul> and inside <ol> as well.

Type 2: Ordered List - <ol>

<ol> is short for Ordered List. Use it when order matters - recipe steps, software installation instructions, priority ranking. The browser automatically adds numbers (1, 2, 3...).

<ol>
    <li>Open the code editor (VS Code)</li>
    <li>Create a new file named index.html</li>
    <li>Write the basic HTML structure</li>
    <li>Save the file and open it in the browser</li>
</ol>

Result in the browser:

  1. Open the code editor (VS Code)
  2. Create a new file named index.html
  3. Write the basic HTML structure
  4. Save the file and open it in the browser

Extra <ol> Attributes

You can control numbering style and starting point:

<!-- Change numbering style -->
<ol type="A">   <!-- A, B, C... -->
    <li>First option</li>
    <li>Second option</li>
</ol>

<ol type="i">   <!-- i, ii, iii... (Roman numerals) -->
    <li>First option</li>
    <li>Second option</li>
</ol>

<!-- Start from a specific number -->
<ol start="5">
    <li>This is item five</li>
    <li>This is item six</li>
</ol>

<!-- Reverse numbering -->
<ol reversed>
    <li>First place (will show the largest number)</li>
    <li>Second place</li>
    <li>Third place</li>
</ol>
type Value Result
type="1" 1, 2, 3... (default)
type="A" A, B, C...
type="a" a, b, c...
type="I" I, II, III... (uppercase Roman)
type="i" i, ii, iii... (lowercase Roman)

Type 3: Description List - <dl>

<dl> is short for Description List. It is designed specifically to display terms with their definitions - like a dictionary, FAQ, or glossary.

It consists of three tags:

  • <dl> - main container
  • <dt> - term (Description Term)
  • <dd> - definition (Description Details)
<dl>
    <dt>HTML</dt>
    <dd>A markup language used to build the structure of web pages.</dd>

    <dt>CSS</dt>
    <dd>A styling language used to design web pages and control their appearance.</dd>

    <dt>JavaScript</dt>
    <dd>A programming language that adds interactivity and motion to web pages.</dd>
</dl>

Result - the browser emphasizes the term and indents the definition:

HTML
A markup language used to build the structure of web pages.
CSS
A styling language used to design web pages.
JavaScript
A programming language that adds interactivity to web pages.

Nested Lists - A List Inside a List

You can place a list inside an <li> to create a multi-level hierarchy. This is commonly used in navigation menus and site maps.

<ul>
    <li>HTML Lessons
        <ul>
            <li>Introduction</li>
            <li>Core tags</li>
            <li>Headings and paragraphs</li>
        </ul>
    </li>
    <li>CSS Lessons
        <ul>
            <li>Selectors</li>
            <li>Colors and fonts</li>
        </ul>
    </li>
    <li>JavaScript Lessons</li>
</ul>

You can also mix types - <ul> inside <ol> and vice versa.

Reference Table - The Three List Types

Type Tag When to Use It Default Appearance
Unordered <ul> Order does not matter - shopping lists, features Bullets before each item
Ordered <ol> Order matters - steps, instructions, ranking Numbers 1, 2, 3...
Description <dl> Terms and definitions - dictionaries, FAQ Term + indented definition

Frequently Asked Questions - FAQ

Can I change the bullet style in <ul>?

Yes, with CSS: ul { list-style-type: square; } (square), or circle (hollow), or none (no bullets) - often used for navigation menus.

Why is <ul> used for navigation menus?

Because navigation links are a list of items with no required order. Then we remove bullets with CSS and lay them out horizontally. This is the best semantic approach for SEO and accessibility.

Can <li> contain more than just text?

Yes, <li> can contain any HTML content: paragraphs, images, links, and even nested lists.

What is the difference between <dt> and <dd>?

<dt> is the term title - like "HTML". <dd> is the definition (detail) - like "A markup language for web pages". One term can have multiple definitions (multiple <dd> items).

Great! You have now mastered all types of HTML lists. In the next lesson we will learn forms - how to build signup forms, login forms, and collect user data.
Smart Editor

Write code and see the result instantly

Try it free