Get Simon & Matt's Photoshop Book!

Photoshop CS3 Layers Bible book cover

Sharpen your Photoshop skills today!

PageKits.com Featured PageKits

Droplet PageKit
Droplet ($39.99)


Naturespace PageKit
Naturespace ($39.99)


See more! > >

 

HTML Lists

Tutorial by Matt Doyle. Level: Beginner. Published on 6 February 2003 in HTML.

Learn how to create HTML lists in your Web page. Covers unordered (bullet) lists, ordered (numbered) lists, and definition lists.

Types of HTML lists

There are 3 basic types of lists that you can produce using HTML. They are:

Unordered lists

Unordered lists are also known as bullet lists or bulleted lists. For example:

  • Apples are green
  • Bananas are yellow
  • Oranges are orange

Ordered lists

These are also known as numbered lists. For example:

  1. Light the blue touch paper.
  2. Stand well back.
  3. Enjoy the fireworks!

Definition lists

Good for making lists where each item needs a summary followed by a more detailed description. For example:

Paris, France
The capital city of France. Famous attractions include the Eiffel Tower and the Notre Dame Cathedral.
Sydney, Australia
The state capital of New South Wales, Australia. Famous attractions include the Sydney Opera House and Harbour Bridge.
London, England
The capital city of England. Famous attractions include Tower Bridge and Big Ben.

Let's explore how to create each of these types of HTML lists.

Creating unordered lists

To create an unordered, or bullet, list you use <ul></ul> tags for the list, and <li></li> tags for the list items.

So, to create the unordered list example above, you'd use:


<ul>
  <li>Apples are green</li>
  <li>Bananas are yellow</li>
  <li>Oranges are orange</li>
</ul>

Creating ordered lists

The method to create ordered (numbered) lists is almost exactly the same as for unordered lists. The only difference is that you use <ol></ol> tags in place of the <ul></ul> tags.

To recreate the ordered list above:


<ol>
  <li>Light the blue touch paper.</li>
  <li>Stand well back.</li>
  <li>Enjoy the fireworks!</li>
</ol>

Creating definition lists

Creating a definition list is a little more complicated than the last 2 types, but it's still pretty easy!

The definition list itself is created with the <dl></dl> tags. Each item in the list consists of a term, created using the <dt></dt> tags, and the indented definition, which uses the <dd></dd> tags.

So, the cities example above is created as follows:


<dl>
  <dt><strong>Paris, France</strong></dt>
  <dd>The capital city of France. Famous attractions
  include the Eiffel Tower and the Notre Dame Cathedral.</dd>
  <dt><strong>Sydney, Australia</strong></dt>
  <dd>The state capital of New South Wales, Australia. Famous
  attractions include the Sydney Opera House and
  Harbour Bridge.</dd>
  <dt><strong>London, England</strong></dt>
  <dd>The capital city of England. Famous attractions 
  include Tower Bridge and Big Ben.</dd>
</dl>

Mixing and matching HTML lists

It's possible to nest lists in HTML. For example, here is a 2-level ordered list:

  1. Chapter 1
    1. Section 1.1
    2. Section 1.2
  2. Chapter 2
    1. Section 2.1
    2. Section 2.2
    3. Section 2.3

...and here's the code for it:


<ol>
  <li>Chapter 1
    <ol>
      <li>Section 1.1</li>
      <li>Section 1.2</li>
    </ol>
  </li>
  <li>Chapter 2
    <ol>
      <li>Section 2.1</li>
      <li>Section 2.2</li>
      <li>Section 2.3</li>
    </ol>
  </li>
</ol>

It's even possible to nest different types of lists together! In this example, the unordered and ordered lists above are nested inside a definition list:

Types of Fruit
  • Apples are green
  • Bananas are yellow
  • Oranges are orange
Firework Instructions
  1. Light the blue touch paper.
  2. Stand well back.
  3. Enjoy the fireworks!

...and here's the code:


<dl>
  <dt><strong>Types of Fruit</strong></dt>
  <dd>
    <ul>
      <li>Apples are green</li>
      <li>Bananas are yellow</li>
      <li>Oranges are orange</li>
    </ul>
  </dd>

  <dt><strong>Firework Instructions</strong></dt>
  <dd>
    <ol>
      <li>Light the blue touch paper.</li>
      <li>Stand well back.</li>
      <li>Enjoy the fireworks!</li>
    </ol>
  </dd>
</dl>

That's about all there is to know about HTML lists. You've looked at creating bullet lists, numbered lists, and definition lists.

Why not have a go at creating a few HTML lists yourself! They're easy to make.

Responses to this article

There are no repsonses yet.

Post a response

Want to add a comment, or ask a question about this article? Post a response.

To post responses you need to be a member. Not a member yet? Signing up is free, easy and only takes a minute or two. Sign up now.

Keep in touch

Subscribe to our feed or follow us on Twitter for news of our latest articles and other fun stuff.

Also, don't forget the free ELATED Extra Newsletter, where you can get more great Web-building articles and tips sent straight to your inbox!

If you need help with a Web-building issue, check out our online Webmaster Forums, where you can get assistance from members of Elated and other webmasters.

Link to this page

Feel free to link to this article in your own Web pages. Click one of the boxes below to select the text, then copy and paste it into your page:



Top of Page

Free email newsletter

The popular ELATED Extra twice-a-month newsletter. Site updates, web tips, and more. Free bonus template when you sign up!

We won't give away your email address. Unsubscribe any time. Privacy
Feed icon Follow us on Twitter