Home Web Development HTML lists

HTML lists

by anupmaurya
36 minutes read

In this article, we’ll learn about HTML Lists, it’s types with examples.

Lists are used to group together related pieces of information so they are clearly associated with each other and easy to read. In modern web development, lists are workhorse elements, frequently used for navigation as well as general content.

The three list types in HTML

There are three list types in HTML:

  • unordered list — used to group a set of related items in no particular order
  • ordered list — used to group a set of related items in a specific order
  • description list — used to display name/value pairs such as terms and definitions

Each list type has a specific purpose and meaning in a web page.

Unordered lists

Unordered (bulleted) lists are used when a set of items can be placed in any order. An example is a programming language list:

Unordered list markup

Unordered lists use one set of <ul></ul> tags wrapped around one or more sets of <li></li> tags:


Ordered lists

Ordered (numbered) lists are used to display a list of items that should be in a specific order. An example , how to run a code in C programming:

  1. Creating a Source Code.
  2. Compile Source Code.
  3. Executing / Running Executable File
  4. Check Result

Ordered lists can be displayed with several sequencing options. The default in most browsers is decimal numbers, but there are others available:

  • Letters
    • Lowercase ascii letters (a, b, c…)
    • Uppercase ascii letters (A, B, C…).
    • Lowercase classical Greek: (έ, ή, ί…)
  • Numbers
    • Decimal numbers (1, 2, 3…)
    • Decimal numbers with leading zeros (01, 02, 03…)
    • Lowercase Roman numerals (i, ii, iii…)
    • Uppercase Roman numerals (I, II, III…)

Ordered list markup

Ordered lists use one set of <ol></ol> tags wrapped around one or more sets of <li></li> tags:

  <li>Creating a Source Code. </li>
  <li>Compile Source Code.</li>
  <li>Executing / Running Executable File</li>
  <li>Check Result</li>  

Beginning ordered lists with numbers other than 1

A common requirement in ordered list usage is to get them to start with a number other than 1 (or i, or I, etc.). This is done using the start attribute, which takes a numeric value.

For example,

  <li>Gather ingredients</li>
  <li>Mix ingredients together</li>
  <li>Place ingredients in a baking dish</li>

<p>Before you place the ingredients in the baking dish, preheat the oven to
180 degrees centigrade/350 degrees fahrenheit in readiness for the next step.</p>

<ol start="4">
  <li>Bake in oven for an hour</li>
  <li>Remove from oven</li>
  <li>Allow to stand for ten minutes</li>

Description lists

Description lists (previously called definition lists, but renamed in HTML5) associate specific names and values within a list.

Description lists are flexible: you can associate more than one value with a single name, or vice versa. For example, the term “coffee” can have several meanings, and you could show them one after the other:


  a beverage made from roasted, ground coffee beans
  a cup of coffee
  a social gathering at which coffee is consumed
  a medium to dark brown colour

Or, you can associate more than one name with the same value. This is useful to show variations of a term, all of which have the same meaning:

fizzy drink

  a sweet, carbonated beverage

Description list markup

Description lists use one set of <dl></dl> tags wrapped around one or more groups of <dt></dt> (name) and <dd></dd> (value) tags. You must pair at least one <dt></dt> with at least one <dd></dd>, and the <dt></dt> should always come first in the source order.

A simple description list of single names with single values would look like this:


This is rendered as follows:


In the following example, we associate more than one value with a name, and vice versa:

  <dd>Value that applies to Name1</dd>
  <dd>Value that applies to both Name2 and Name3</dd>
  <dd>One value that applies to Name4</dd>
  <dd>Another value that applies to Name4</dd>

That code would render like this:

  Value that applies to Name1
  Value that applies to both Name2 and Name3
  One value that applies to Name4
  Another value that applies to Name4

You may also like

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.