Docs LogoDocs

Lists - Organizing Content

Documentation for Lists - Organizing Content.

Lists - Organizing Content

What are Lists?

Lists are used to group related items together in an ordered or unordered way.

Definition: HTML provides three types of lists: ordered lists (<ol>) for numbered sequences, unordered lists (<ul>) for bullet points, and description lists (<dl>) for term-definition pairs. Lists are block elements that can be nested.

Types of Lists

TypeElementPurposeExample Use
Unordered List<ul>Items without sequenceFeatures, menu items
Ordered List<ol>Numbered/sequential itemsSteps, rankings
Description List<dl>Term and definition pairsGlossary, FAQs

Unordered Lists

<ul>
  <li>First item</li>
  <li>Second item</li>
  <li>Third item</li>
</ul>

Styling List Markers (CSS)

/* Bullet types */
ul {
  list-style-type: disc;
} /* ● (default) */
ul {
  list-style-type: circle;
} /* ○ */
ul {
  list-style-type: square;
} /* ■ */
ul {
  list-style-type: none;
} /* No bullet */

/* Custom bullets */
ul {
  list-style-image: url("bullet.png");
}

Ordered Lists

<ol>
  <li>First step</li>
  <li>Second step</li>
  <li>Third step</li>
</ol>

Ordered List Attributes

AttributePurposeExample
typeNumbering styletype="A" for A, B, C
startStarting numberstart="5" starts at 5
reversedCount backwardsreversed
<!-- Different numbering types -->
<ol type="1">
  ...
</ol>
<!-- 1, 2, 3 (default) -->
<ol type="A">
  ...
</ol>
<!-- A, B, C -->
<ol type="a">
  ...
</ol>
<!-- a, b, c -->
<ol type="I">
  ...
</ol>
<!-- I, II, III -->
<ol type="i">
  ...
</ol>
<!-- i, ii, iii -->

<!-- Starting from specific number -->
<ol start="5">
  <li>This is item 5</li>
  <li>This is item 6</li>
</ol>

<!-- Reversed order -->
<ol reversed>
  <li>Third place</li>
  <li>Second place</li>
  <li>First place</li>
</ol>

<!-- Specific value for an item -->
<ol>
  <li>Item 1</li>
  <li value="10">This is item 10</li>
  <li>This is item 11</li>
</ol>

Description Lists

<dl>
  <dt>HTML</dt>
  <dd>HyperText Markup Language - the standard markup for web pages.</dd>

  <dt>CSS</dt>
  <dd>Cascading Style Sheets - used for styling web pages.</dd>

  <dt>JavaScript</dt>
  <dd>A programming language for web interactivity.</dd>
</dl>

Multiple Terms or Descriptions

<!-- Multiple terms for one description -->
<dl>
  <dt>HTTP</dt>
  <dt>HyperText Transfer Protocol</dt>
  <dd>The protocol used for web communication.</dd>
</dl>

<!-- One term with multiple descriptions -->
<dl>
  <dt>Web Browser</dt>
  <dd>Software for accessing the World Wide Web.</dd>
  <dd>Examples: Chrome, Firefox, Safari.</dd>
</dl>

Nested Lists

<!-- Unordered with nesting -->
<ul>
  <li>
    Frontend
    <ul>
      <li>HTML</li>
      <li>CSS</li>
      <li>JavaScript</li>
    </ul>
  </li>
  <li>
    Backend
    <ul>
      <li>Node.js</li>
      <li>Python</li>
      <li>Java</li>
    </ul>
  </li>
</ul>

<!-- Mixed list types -->
<ol>
  <li>
    Prepare ingredients
    <ul>
      <li>2 cups flour</li>
      <li>1 cup sugar</li>
      <li>3 eggs</li>
    </ul>
  </li>
  <li>Mix together</li>
  <li>Bake at 350°F</li>
</ol>
<!-- Navigation menu -->
<nav>
  <ul>
    <li><a href="/">Home</a></li>
    <li><a href="/about">About</a></li>
    <li>
      <a href="/services">Services</a>
      <ul>
        <li><a href="/services/web">Web Development</a></li>
        <li><a href="/services/mobile">Mobile Apps</a></li>
      </ul>
    </li>
    <li><a href="/contact">Contact</a></li>
  </ul>
</nav>

Interview Questions & Answers

Q1: What are the three types of lists in HTML?

HTML provides three list types: Unordered lists (<ul>) display items with bullets and are for collections without inherent sequence like features or navigation menus. Ordered lists (<ol>) display numbered items for sequential content like steps or rankings. Description lists (<dl>) pair terms (<dt>) with descriptions (<dd>) for glossaries, FAQs, or metadata. Each type has semantic meaning, so choose based on content nature, not visual preference - use CSS to change appearance.


Q2: How do you change the numbering style in ordered lists?

Use the type attribute: type="1" for numbers (default), type="A" for uppercase letters, type="a" for lowercase letters, type="I" for uppercase Roman numerals, type="i" for lowercase Roman numerals. For more control, use CSS list-style-type which offers additional options like decimal-leading-zero or language-specific numbering. The CSS approach is preferred for separation of concerns. You can also use start to begin at a specific number and value on individual <li> elements.


Q3: When should you use a description list vs other list types?

Use description lists when you have term-definition pairs, name-value relationships, or metadata. Common uses include glossaries, FAQs (question as term, answer as description), product specifications, article metadata (author, date, category), and key-value data. Don't use them just for visual indentation. Each <dt> introduces a term, and <dd> provides its description. You can have multiple <dt> elements for one <dd> or multiple <dd> elements for one <dt>.


Q4: How do you properly nest lists?

Place the nested list inside the parent <li> element, after the text but before the closing </li>. The nested list must be a complete list element. You can nest any list type inside any other. Proper nesting creates a valid DOM tree and maintains accessibility. Screen readers announce list levels. Don't place lists directly inside <ul> or <ol> - they must be inside <li>.


Q5: Why use lists for navigation menus?

Lists are semantically correct for navigation because navigation is fundamentally a list of links. Screen readers announce "navigation with X items" and allow users to skip between items. Lists provide proper structure for styling with CSS. They're easier to maintain than raw links with separators. Using <ul> inside <nav> is the standard pattern for accessible navigation.

Last updated on July 15, 2026

On this page