What are lists?
Often, we will want to include some kind of list on our page. A list is simply of collection of items of information that are connected by a common theme. Here are some examples of lists:
- My favourite bands
- Presidents of the United States
- Wettest countries of the world
- Things to do before I die
The collection of example lists above is in itself a list.
<ul> Unordered List
A unordered list is one in which there is no particular order to the list entries that it contains. For example, „different colours“.
<li> List Item
We enclose each item in our list in <li></li> tags:
<p>Some different colours:</p>
The previous code would display something like this:
Some different colours:
<ol> Ordered List
An ordered list is one in which there is an order to the list entries that it contains. That is, the entries would make sense if they were consecutively labelled 1, 2, 3, 4, etc. For example:
<p>My greatest musical influences:</p>
<li>Ali Farka Toure</li>
<li>Asian Dub Foundation</li>
This would display by default like this:
My greatest musical influences:
- PR Sarkar
- Bob Dylan
- Ali Farka Toure
- Van Morrison
- Pink Floyd
- Asian Dub Foundation
Using a List for Site Navigation
On our website, we will have a collection of pages that link together. The pages within that collection will have some kind of relative importance between each other. We will want to make a navigation area on each of our web pages, so that the user can quickly navigate their way through our site. This would be a series of links from our web page to other pages.
It makes good sense to make that collection of links into a list. For example:
<li><a href=“index.htm“>Home Page</a></li>
<li><a href=“contact.htm“>Contact Me</a></li>
This would display something like this:
- Home Page
- Contact Me
Later on, we will learn how to style our pages so that they display in the browser just how we want them to. By structuring our site navigation as an HTML list, we open up lots of possibilities for controlling the way that it displays. (See CSS stylesheets).