WebThings - by Jan Weijers
All chapters...
Table of contents
Introduction
A simple HTML document
Images
Lists
Links
Tables
Frames
Forms
Cascading style sheets
JavaScript
Programming in PHP
Server side includes
CGI & Perl
Extended characters
Examples of colours
Learn more
Software
Recent changes
Alphabetical index
In this chapter...
Unordered list
Ordered list
Definition lists
Nested lists

 

 

Taalkeuze...
U hebt gekozen om Engels als eerste taal te gebruiken.Nederlands vlaggetje Klik hier om te kiezen voor Nederlands.

Lists

List are a practical and simple method for ordering information.

Unordered list

The UL element, an unordered list, shows items with just a plain bullet before them. Every item in the list starts with the LI (list item) element. You can close each list item with an </LI> tag but this is not obligatory:

<UL>
<LI>Dog</LI>
<LI>Cat</LI>
<LI>Cow</LI>
</UL>

  • Dog
  • Cat
  • Cow

Both the UL and LI element can take the attribute TYPE. This can take the values of "disc", "circle" or "square". If you include this attribute in the UL element, it will affect the whole list. If you include it in an LI element, the attribute will affect that item only:

<UL>
<LI STYLE="list-style-type:disc">Dog
<LI STYLE="list-style-type:circle">Cat
<LI STYLE="list-style-type:square">Cow
<LI>Snake
</UL>

  • Dog
  • Cat
  • Cow
  • Snake

As you can see from these two examples, the default for TYPE is "disc". The TYPE attribute has been deprecated, in favour of style sheets.

To the top

Ordered list

In the ordered list each item gets a number, automatically. The items are also indented. Each item should start with the LI element. Ordered lists look like this:

<OL>
<LI>Train
<LI>Airplane
</OL>

  1. Train
  2. Airplane

The result is almost the same as an unordered list, except that in the unordered list the items do not get a number but a bullet before them.

Both the OL and the LI element can be assigned different styles. If you put the TYPE attribute in the <OL> tag is influences the whole list, it you put it in the <LI> tag, it affects that item only.

<OL STYLE="list-style-type:hebrew">
<LI>Bogart
<LI STYLE="list-style-type:decimal-leading-zero">Reynolds
<LI STYLE="list-style-type:lower-roman">Bergman
<LI STYLE="list-style-type:decimal">Hoffman
<LI STYLE="list-style-type:upper-roman">Bacall
<LI STYLE="list-style-type:georgian">Caine
<LI STYLE="list-style-type:armenian">Pacino
<LI STYLE="list-style-type:cjk-ideographic">Quaid
<LI STYLE="list-style-type:hiragana">Goodman
<LI STYLE="list-style-type:katakana">McQueen
<LI STYLE="list-style-type:hiragana-iroha">Welles
</OL>

  1. Bogart
  2. Reynolds
  3. Bergman
  4. Hoffman
  5. Bacall
  6. Caine
  7. Pacino
  8. Quaid
  9. Goodman
  10. McQueen
  11. Welles

You will probably see that your browser does not recognise all the different ways of numbers. Normally, the ones not recognised will be replaces by normal, decimal numbering.

To the top

Definition lists

A definition list (also referred to as glossary list) has elements that consist of two parts: a term and its definition. For example:

<DL>
<DT>A Cat
<DD>A furry, four-legged animal
<DT>A Snake
<DD>A legless thing that slithers on the ground
</DL>

A Cat
A furry, four-legged animal
A Snake
A legless thing that slithers on the ground

DD and DT elements may end with a </DD> and </DT> tag respectively but this is optional. Also, you can have more than one term followed by more than one definition:

<DL>
<DT>Car</DT>
<DT>Automobile</DT>
<DD>A four-wheeled passenger car</DD>
<DD>General term for motorised vehicles</DD>
</DL>

Car
Automobile
A four-wheeled passenger car
General term for motorised vehicles
To the top

Nested lists

It is possible to put lists within lists:

<OL>
<LI>Train
  <UL>
  <LI>Intercity
  <LI>Regional
  <LI>Local
  </UL>
<LI>Airplane
<LI>Boat
<LI>Car
</OL>

  1. Train
    • Intercity
    • Regional
    • Local
  2. Airplane
  3. Boat
  4. Car

With nested lists you can use all the options and attributes mentioned in this chapter.

To the top

 

Feedback welcome...

Please let me know your opinion about this guide, information you would like to be added or any errors you have discovered. Click here.

 

Open standards...

This site conforms completely to open standards of the World Wide Web Consortium (W3C). Click on the logos to verify that.

HTML 4 logo

CSS logo

 

 

©1995-2010 Jan Weijers, the Netherlands. All rights reserved.
No reproduction by any means or in any language without prior permission of the author.