Support0

HTML lists playground

Combine the three HTML list types, create nested levels, and generate semantic markup with ul, ol, li, dl, dt, and dd.

Ask AI

HTML lists playground

Response generated with openai/gpt-5.4-nano. AI can make mistakes. Always review the result.

Unordered list

  • Milk
  • Eggs
  • Bread
  • Hummus
HTML
<ul>
  <li>Milk</li>
  <li>Eggs</li>
  <li>Bread</li>
  <li>Hummus</li>
</ul>

Educational guide to HTML lists

Structure groups, sequences, and descriptions

Choose ul, ol, or dl according to the relationship between your data. Learn to nest items, continue or reverse numbering, and keep a readable structure beyond its bullets.

Mental model

Meaning determines the element; the marker only helps present it.

  1. Group: ul

    Changing item order does not change the meaning.

  2. Sequence: ol

    The order of steps or positions is part of the meaning.

  3. Associations: dl

    One or more terms relate to one or more descriptions.

Choose the relationship your content expressesStatic choice diagram: related resources, ordered steps, and terms with descriptions. The following examples show actual HTML structures.

A list expresses a relationship between items. Use ul for materials or resources with no meaningful sequence; ol for instructions, rankings, or a chronology whose order matters; dl for a glossary or name–value data. To compare the same columns across multiple records, a table may express the relationship better. Do not choose a list just to obtain indentation.

Structure and nested lists

A list contains items; each sublist belongs to a particular item.

ul and ol group li items. Write each item inside its li and put a sublist inside the li it belongs to, before the closing tag. You can alternate ul and ol at each level when the meaning changes. An li can contain paragraphs, links, or other flow content; do not put a sublist alongside the li elements or simulate nesting with spaces or br breaks.

A group with no required sequence

  • Requirements document
  • Test data
  • Style guide
All three materials are items in the same ul. Their order can change without turning the group into a procedure; the bullets are native.
A group with no required sequence
<div class="lists-guide-scene">
  <ul>
    <li>Requirements document</li>
    <li>Test data</li>
    <li>Style guide</li>
  </ul>
</div>
.lists-guide-scene {
  min-inline-size: 0;
  overflow-wrap: anywhere;

  :is(ul, ol) {
    margin: 0;
    padding-inline-start: 1.5em;
  }

  li + li,
  li > :is(ul, ol) {
    margin-block-start: 0.5rem;
  }

  dl {
    margin: 0;
  }

  dt {
    font-weight: 600;
  }

  dd {
    margin: 0;
    margin-inline-start: 1.5em;
  }

  dl > div + div {
    margin-block-start: 1rem;
  }
}

Ordered steps with unordered checks

  1. Prepare the release
    • Review the documentation
    • Run the tests
  2. Publish the package
Prepare the release first, then publish it. Both checks belong to the first step: their ul is inside the first li of the ol.
Ordered steps with unordered checks
<div class="lists-guide-scene">
  <ol>
    <li>
      Prepare the release
      <ul>
        <li>Review the documentation</li>
        <li>Run the tests</li>
      </ul>
    </li>
    <li>Publish the package</li>
  </ol>
</div>
.lists-guide-scene {
  min-inline-size: 0;
  overflow-wrap: anywhere;

  :is(ul, ol) {
    margin: 0;
    padding-inline-start: 1.5em;
  }

  li + li,
  li > :is(ul, ol) {
    margin-block-start: 0.5rem;
  }

  dl {
    margin: 0;
  }

  dt {
    font-weight: 600;
  }

  dd {
    margin: 0;
    margin-inline-start: 1.5em;
  }

  dl > div + div {
    margin-block-start: 1rem;
  }
}

Code indentation helps readability, but tags create the hierarchy. In this playground, two spaces per level and the Mixed mode prefixes are a custom input syntax; the lab converts them into HTML. Browsers do not interpret those prefixes as Markdown. Mixed mode preserves the start of each ordered block, while the start/type/reversed controls apply to ol mode.

start, reversed, type, and value

Change numbering without reordering nodes or writing numbers by hand.

start sets an initial integer, even when type uses letters or Roman numerals: start="4" with type="A" begins at D. ol accepts type="1", "a", "A", "i", or "I". Use this attribute when the ordinal style is part of a reference to the content; for a purely visual preference, use CSS list-style-type. The old type attribute on ul or li is not recommended.

Continue a series of sections

  1. Scope
  2. Constraints
  3. Validation
start=4 and type=A display D, E, and F. start is still a number; do not write start="D". Content order is preserved.
Continue a series of sections
<div class="lists-guide-scene">
  <ol start="4" type="A">
    <li>Scope</li>
    <li>Constraints</li>
    <li>Validation</li>
  </ol>
</div>
.lists-guide-scene {
  min-inline-size: 0;
  overflow-wrap: anywhere;

  :is(ul, ol) {
    margin: 0;
    padding-inline-start: 1.5em;
  }

  li + li,
  li > :is(ul, ol) {
    margin-block-start: 0.5rem;
  }

  dl {
    margin: 0;
  }

  dt {
    font-weight: 600;
  }

  dd {
    margin: 0;
    margin-inline-start: 1.5em;
  }

  dl > div + div {
    margin-block-start: 1rem;
  }
}

Count down with an implicit start

  1. Bronze
  2. Silver
  3. Gold
Without start, reversed begins at the number of items in this list: 3, 2, and 1. Bronze, silver, and gold keep their DOM order.
Count down with an implicit start
<div class="lists-guide-scene">
  <ol reversed>
    <li>Bronze</li>
    <li>Silver</li>
    <li>Gold</li>
  </ol>
</div>
.lists-guide-scene {
  min-inline-size: 0;
  overflow-wrap: anywhere;

  :is(ul, ol) {
    margin: 0;
    padding-inline-start: 1.5em;
  }

  li + li,
  li > :is(ul, ol) {
    margin-block-start: 0.5rem;
  }

  dl {
    margin: 0;
  }

  dt {
    font-weight: 600;
  }

  dd {
    margin: 0;
    margin-inline-start: 1.5em;
  }

  dl > div + div {
    margin-block-start: 1rem;
  }
}

Resume numbering at an item

  1. First section in this excerpt
  2. Section resumed after an omission
  3. Following section
The list starts at 4, li value=10 sets the next ordinal to 10, and the third item continues at 11. value affects numbering; it is not a stable identifier.
Resume numbering at an item
<div class="lists-guide-scene">
  <ol start="4">
    <li>First section in this excerpt</li>
    <li value="10">Section resumed after an omission</li>
    <li>Following section</li>
  </ol>
</div>
.lists-guide-scene {
  min-inline-size: 0;
  overflow-wrap: anywhere;

  :is(ul, ol) {
    margin: 0;
    padding-inline-start: 1.5em;
  }

  li + li,
  li > :is(ul, ol) {
    margin-block-start: 0.5rem;
  }

  dl {
    margin: 0;
  }

  dt {
    font-weight: 600;
  }

  dd {
    margin: 0;
    margin-inline-start: 1.5em;
  }

  dl > div + div {
    margin-block-start: 1rem;
  }
}

reversed is Boolean: its presence activates descending numbering; reversed="false" activates it too. With an explicit start, it counts down from that value; without one, it starts from the number of items owned by the list. It does not change the DOM or act like flex-direction: column-reverse. li value accepts an integer inside ol and following items continue from it, descending when the list is reversed. HTML allows zero or negative integers; the playground limits start to 1–20. The examples also demonstrate the implicit reversed start and li value.

Terms and descriptions with dl

A relationship can have more than one term or more than one description.

dl groups dt elements followed by dd elements, with no li. Each group contains one or more dt followed by one or more dd; it does not require pairs of exactly two nodes. You can wrap each complete group in a div, as in the example, or place all groups directly inside dl. Use one of these structures consistently and keep each description with its terms.

An alternative name and multiple values

API
Application programming interface
A contract that lets two programs exchange information.
Accepted formats
JSON for structured data.
CSV for tabular data.
API and its expanded name share a description. The term Accepted formats has two descriptions. The div elements group complete associations; they neither create columns nor change their meaning.
An alternative name and multiple values
<div class="lists-guide-scene">
  <dl>
    <div>
      <dt>API</dt>
      <dt>Application programming interface</dt>
      <dd>A contract that lets two programs exchange information.</dd>
    </div>
    <div>
      <dt>Accepted formats</dt>
      <dd>JSON for structured data.</dd>
      <dd>CSV for tabular data.</dd>
    </div>
  </dl>
</div>
.lists-guide-scene {
  min-inline-size: 0;
  overflow-wrap: anywhere;

  :is(ul, ol) {
    margin: 0;
    padding-inline-start: 1.5em;
  }

  li + li,
  li > :is(ul, ol) {
    margin-block-start: 0.5rem;
  }

  dl {
    margin: 0;
  }

  dt {
    font-weight: 600;
  }

  dd {
    margin: 0;
    margin-inline-start: 1.5em;
  }

  dl > div + div {
    margin-block-start: 1rem;
  }
}

dl is not limited to dictionary definitions: it also suits metadata or names associated with values. Do not choose it just to draw two columns or for a conversation between speakers. If multiple rows share column headers and you need to compare them, use table. The playground offers one term and one description per line; the example extends that relationship to multiple names or values.

Accessible presentation

Preserve relationships, reading order, and native actions when changing appearance.

Keep enough markers and indentation to read the levels. The examples adjust spacing and indentation for readability and preserve native markers. Numbers written as text, bullets in ::before, and line breaks do not replace list structure. If an ordinal needs to be a link destination, add a stable id: start or value does not create one.

Avoid routinely adding role="list" to every list. There is an exception to test: Safari may remove ul/ol semantics with list-style: none outside nav. If your design needs to remove markers, MDN documents role="list" as a way to preserve list announcements. These examples keep native markers. Screen readers present dl and its groups differently; do not add term/definition roles by intuition or promise identical counts and navigation everywhere.

A reading list needs neither tabindex nor arrow-key handlers. Links and buttons inside li keep their native keyboard behavior. Do not turn a navigation list into role="menu" just because of its appearance or visually reorder items with CSS in a way that contradicts the DOM. Check enlarged text, nested levels, action focus, both themes, and forced colors.

Common pitfalls

Check the semantic relationship before correcting markers with CSS.

The sublist does not belong to an item

Expected result
Express that several checks belong to one step.
Cause
ul or ol is placed directly inside another list, outside an li.
Solution
Move the sublist inside the corresponding li, before closing that item.

The list does not begin at the expected letter

Expected result
Start an alphabetical series at D.
Cause
start="D" is used, or the counter is confused with its representation.
Solution
Use start="4" and type="A"; check that CSS does not override list-style-type.

reversed="false" still counts down

Expected result
Disable descending numbering.
Cause
Boolean attributes are activated by presence, not by their value text.
Solution
Remove reversed. To change content order, update the DOM consistently.

A glossary is presented as unrelated items

Expected result
Associate each term with its descriptions.
Cause
li is used inside dl, or terms and descriptions are split for visual layout.
Solution
Use groups of dt followed by dd; preserve associations as the layout changes.

Support and compatibility

Tag support does not guarantee identical assistive output.

HTML lists and description lists are Baseline Widely Available. MDN and BCD document support for ul, ol, dl, and start/reversed/type in major browsers. These recipes need no polyfills or JavaScript. Marker styling, pronunciation, and assistive navigation can vary with language, system, browser, and screen reader.

Without supporting styles, the markup keeps its native structure and numbering; without JavaScript, the guide and its examples remain present. Customized markers or counters need their own support and accessibility review. Caption text explains the expected result but does not by itself demonstrate what assistive technology announces.