HTML / HTML Lists

Creating Ordered and Unordered Lists

A tutorial about Creating Ordered and Unordered Lists

Tutorial 1 of 5 5 resources in this section

Section overview

5 resources

Explains how to create and format ordered, unordered, and description lists.

Creating Ordered and Unordered Lists

1. Introduction

In this tutorial, we will learn how to create ordered and unordered lists in HTML. HTML allows us to structure content on the web in various ways, and one of the most common ways is using lists.

By the end of this tutorial, you will be able to:
- Understand what ordered and unordered lists in HTML are
- Create your own ordered and unordered lists

Prerequisites:
- Basic understanding of HTML

2. Step-by-Step Guide

HTML provides two main types of lists:
- Ordered lists: These are numbered lists
- Unordered lists: These are bullet-point lists

To create an ordered list in HTML, we use the <ol> tag. Each item in the list is marked with the <li> tag.

The same goes for unordered lists, but instead of the <ol> tag, we use the <ul> tag.

3. Code Examples

Ordered List

<!-- This is an ordered list -->
<ol>
  <!-- Each list item is marked with the `li` tag -->
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ol>

When you run this code in a browser, you will see a numbered list as follows:

  1. Item 1
  2. Item 2
  3. Item 3

Unordered List

<!-- This is an unordered list -->
<ul>
  <!-- Each list item is marked with the `li` tag -->
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ul>

When you run this code in a browser, you will see a bullet-point list as follows:

  • Item 1
  • Item 2
  • Item 3

4. Summary

In this tutorial, we learned about ordered and unordered lists in HTML. We learned that ordered lists are used for items that need to be in a specific order, while unordered lists are used for items that don't need to be in a specific order.

Further learning could include nested lists, where you put a list within a list, and other types of lists, such as description lists.

5. Practice Exercises

  1. Create an ordered list with the names of your top 3 favorite movies.
  2. Create an unordered list with the names of your favorite foods.
  3. Create an ordered list of your top 3 favorite books, each with an unordered list of main characters beneath it.

Solutions:
1. Ordered list of favorite movies:

<ol>
  <li>The Shawshank Redemption</li>
  <li>The Godfather</li>
  <li>The Dark Knight</li>
</ol>
  1. Unordered list of favorite foods:
<ul>
  <li>Pizza</li>
  <li>Burger</li>
  <li>Pasta</li>
</ul>
  1. Ordered list of favorite books with nested unordered lists:
<ol>
  <li>
    Harry Potter
    <ul>
      <li>Harry Potter</li>
      <li>Hermione Granger</li>
      <li>Ron Weasley</li>
    </ul>
  </li>
  <li>
    The Lord of the Rings
    <ul>
      <li>Frodo Baggins</li>
      <li>Samwise Gamgee</li>
      <li>Gandalf</li>
    </ul>
  </li>
  <li>
    Game of Thrones
    <ul>
      <li>Jon Snow</li>
      <li>Daenerys Targaryen</li>
      <li>Tyrion Lannister</li>
    </ul>
  </li>
</ol>

Practice further by creating lists within lists, and try to style them using CSS.

Need Help Implementing This?

We build custom systems, plugins, and scalable infrastructure.

Discuss Your Project

Related topics

Keep learning with adjacent tracks.

View category

CSS

Master CSS to style and format web pages effectively.

Explore

JavaScript

Learn JavaScript to add interactivity and dynamic behavior to web pages.

Explore

Python

Explore Python for web development, data analysis, and automation.

Explore

SQL

Learn SQL to manage and query relational databases.

Explore

PHP

Master PHP to build dynamic and secure web applications.

Explore

Popular tools

Helpful utilities for quick tasks.

Browse tools

Favicon Generator

Create favicons from images.

Use tool

Fake User Profile Generator

Generate fake user profiles with names, emails, and more.

Use tool

Image Converter

Convert between different image formats.

Use tool

MD5/SHA Hash Generator

Generate MD5, SHA-1, SHA-256, or SHA-512 hashes.

Use tool

Interest/EMI Calculator

Calculate interest and EMI for loans and investments.

Use tool

Latest articles

Fresh insights from the CodiWiki team.

Visit blog

AI in Drug Discovery: Accelerating Medical Breakthroughs

In the rapidly evolving landscape of healthcare and pharmaceuticals, Artificial Intelligence (AI) in drug dis…

Read article

AI in Retail: Personalized Shopping and Inventory Management

In the rapidly evolving retail landscape, the integration of Artificial Intelligence (AI) is revolutionizing …

Read article

AI in Public Safety: Predictive Policing and Crime Prevention

In the realm of public safety, the integration of Artificial Intelligence (AI) stands as a beacon of innovati…

Read article

AI in Mental Health: Assisting with Therapy and Diagnostics

In the realm of mental health, the integration of Artificial Intelligence (AI) stands as a beacon of hope and…

Read article

AI in Legal Compliance: Ensuring Regulatory Adherence

In an era where technology continually reshapes the boundaries of industries, Artificial Intelligence (AI) in…

Read article

Need help implementing this?

Get senior engineering support to ship it cleanly and on time.

Get Implementation Help