Introduction Document Structure Cascading Style Sheets Text Formatting Lists Links Tables Images Forms Frames Appendix - XHTML Elements Site Home

XHTML Reference Guide

Lists

Unordered List

This is a bullet pointed list. The list opens with the <ul> tag and closes with a </ul> tag. A <li> tag is used to specify the bullet pointed text.

Example
<ul>
<li>England</li>
<li>New Zealand</li>
<li>Australia</li>
</ul>

will display as follows:

Items can be indented by nesting one list within another. The type of bullet point can also be changed. Attributes for all list types were deprecated in HTML 4.01 and so style sheets should now be used to achieve the desired effects.

Example
<ul>
   <li>England
      <ul>
         <li>NEC Harlequins</li>
         <li>London Wasps</li>
         <li>London Irish</li>
     </ul>
   </li>
   <li>New Zealand
      <ul>
         <li>Auckland Blues</li>
         <li>Canterbury Crusaders</li>
         <li>Otago Highlanders</li>
     </ul>
   </li>
   <li style="list-style-type:circle">Australia
      <ul style="list-style-type:square">
         <li>NSW Waratahs</li>
         <li>ACT Brumbies</li>
         <li>Queensland Reds</li>
     </ul>
   </li>
</ul>

results in:

The England and New Zealand lists have the default bullet point types, but note that Australia has a hollow circle and that the team list has square bullet points. A single item or a complete list can have its bullet point type changed by using the CSS2 list-style-type property. Specifying "list-style-type: none" will remove the bullet points.

Top

Ordered List

An ordered list works in much the same way as an unordered one, only instead of bullet points, numbers and letters are used. The <ol> tag is used for ordered lists.

Example
<ol>
<li>England</li>
<li>New Zealand</li>
<li>Australia</li>
<li>South Africa</li>
</ol>

will display as follows:

  1. England
  2. New Zealand
  3. Australia
  4. South Africa

As with unordered lists, lists may be nested and the numbering system may changed to a variety of choices by using the CSS list-style-type property as demonstrated in the following example.

Example
<ol>
   <li>England
      <ol  style="list-style-type: upper-roman">
         <li>NEC Harlequins</li>
         <li>London Wasps</li>
      </ol>
   </li>
   <li>New Zealand
      <ol style="list-style-type: lower-roman">
         <li>Auckland Blues</li>
         <li>Canterbury Crusaders</li>
      </ol>
   </li>
   <li>Australia
      <ol style="list-style-type: upper-alpha">
         <li>NSW Waratahs</li>
         <li>ACT Brumbies</li>
      </ol>
   </li>
   <li>South Africa
      <ol style="list-style-type: lower-alpha">
         <li>Natal Sharks
         <li>Blue Bulls</li>
      </ol>
   </li>
</ol>

will display as:

  1. England
    1. NEC Harlequins
    2. London Wasps
  2. New Zealand
    1. Auckland Blues
    2. Canterbury Crusaders
  3. Australia
    1. NSW Waratahs
    2. ACT Brumbies
  4. South Africa
    1. Natal Sharks
    2. Blue Bulls
Top

Definition List

These are lists without bullet points or numbers but with indentation. They are intended for lists of terms and their definitions. Three different tags are used, <dl>, <dt> and <dd>.

Example
<b>VAGen Return Codes</b>
<dl>
<dt>EOF</dt>
   <dd> End of File</dd>
<dt>FMT</dt>
   <dd> File format error</dd>
<dt>FNF</dt>
   <dd> File not found</dd>
<dt>NRF</dt>
   <dd>No record found</dd>
</dl>

displays as:

VAGen Return Codes
EOF
End of File
FMT
File format error
FNF
File not found
NRF
No record found

In the past these tags have been used to produce indentation. This is most definitely not recommended! The CSS margin, padding and text-indent properties may be, and should be, used to achieve this sort of indentation a lot more effectively.

Top

Valid XHTML 1.0! Valid CSS2