HTML 4 - User's Guide
Lists and the OL, UL, DL elements
1. SAMPLES
1.1 An ordered list
<HTML><HEAD><TITLE>ORDERED LIST</TITLE> <META http-equiv="Content-Type" content="text/html"> <LINK rel="stylesheet" type="text/css" href="../Styles/HatayBook.css"> <STYLE>To see how the document is displayed, please click hereOL.chapters
{list-style-type: upper-roman}OL.articles
{list-style-type: lower-alpha} </STYLE> </HEAD> <BODY> North America<OL
class="chapters"><LI>
Introduction</LI>
<LI>
Overview</LI>
<LI>
Canada</LI>
<OL
class="paragraphs"><LI>
The Geography<OL
class="articles"><LI>
The Canadian Shield<LI>
The Interior Plains<LI>
The Great Lakes and St Laurence lowlands<LI>
The Canadian Cordillera<LI>
Appachian Canada<LI>
The Artic Islands</OL>
<LI>
The Economy<OL
class="articles"><LI>
Industry<LI>
Agriculture<LI>
Services</OL>
</OL>
<LI>
The United States<OL
class="paragraphs"><LI>
The geography<OL
class="articles"><LI>
The East<LI>
The Middle West<LI>
The Rocky Mountains<LI>
The West<LI>
The South</OL>
<LI>
The economy<OL
class="articles"><LI>
Industry<LI>
Agriculture<LI>
Services</OL>
</OL>
<LI>
Mexico</LI>
<OL
class="paragraphs"><LI>
The Geography<OL
class="articles"><LI>
Baja California<LI>
The northern regions<LI>
The western and central regions<LI>
The southern regions</OL>
<LI>
The Economy<OL
class="articles"><LI>
Industry<LI>
Agriculture<LI>
Services</OL>
</OL>
</OL>
</BODY></HTML>
An ordered list is defined by an OL element. The lines in the list are defined by LI elements. So the struture the code is simple enough:
<OL ...>
<LI>...
<LI>...
...
</OL>
Now, in place of a line, you can put an embedded list. You see it here:
<OL
class="chapters"><LI>
Introduction</LI>
<LI>
Overview</LI>
<LI>
Canada</LI>
<OL
class="paragraphs"></OL>
<LI>
The United States</LI>
</OL>
list-style-type
property of the OL
element - in the STYLE
element of the above example, this property is defined for 2 classes of the OL
element: the 'chapters' and the 'articles' classes (what you see is how classes of an element are denoted -- for more details, please see the chapter on styles):- | the value 'upper-roman' causes the roman numeral in upper case to be used |
- | the value 'lower-alpha', the alphabetic characters in lower case |
1.2 An unordered list
<HTML><HEAD><TITLE>AN UNORDERED LIST</TITLE>
<META http-equiv="Content-Type" content="text/html">
<STYLE>
UL.class
{list-style-type:square}
UL.animals
{list-style-image:url(../Images/MyArrow.bmp)}
</STYLE>
</HEAD>
<BODY>
<UL
class="class">
<LI>
Mammals
<UL
class="animals">
<LI>
Koala
<LI>
Raccoon
<LI>
Reedbuck
</UL>
<LI>
Birds
<UL
class="animals">
<LI>
Toucan
<LI>
Hummingbird
<LI>
Magpie
</UL>
<LI>
Fishes
<UL
class="animals">
<LI>
Piranha
<LI>
Perch
<LI>
Zander
</UL>
<UL>
</BODY></HTML>
- | with the 'list-style-type', you can choose from among these symbols: - disc (initial value) - circle - square |
- | with the 'list-style-image', you can reference an image defined in an external image file: here, the lines contained in a UL element in the "animals" class are preceded by the image contained in the MyArrow.bmp file |
1.3 A definition list
<HTML><HEAD><TITLE>A DEFINITION LIST</TITLE>
<META http-equiv="Content-Type" content="text/html">
</HEAD>
<BODY>
DEFINITIONS
<DL>
<DT>
Block
<DD>
A block box is formed by more than one logical line. When an element is rendered in a block box, the box occupies a range of lines of its own, unless it is floated. A floated box lets lines from the surrounding text flow on its right or its left.
<DT>
Box
<DD>
An element is rendered on the visual medium, in a rectangular area called <b style="color:red">box</b>. A box can be of one of the types:<br>
- in-line box<br>
- block box<br>
<DT>
In-line
<DD>
An in-line box forms one logical line. When an element is rendered in an in-line box, the box is displayed on the same line as the text that precedes it. If the physical line cannot accommodate the box, several lines are used as needed. Free space after the last line is available for the information coming after the element
</DL>
</BODY></HTML>
The DL
element is used to define a definition list:
- | the DT element contains the term to define |
- | the DD element contains the definition |
1.4 More on the use of definition lists
<HTML><HEAD><TITLE></TITLE> <META http-equiv="Content-Type" content="text/html"> <STYLE>To see how the page is displayed, please click hereDT.order
{font-weight:bold; color:#DD0000;}DT.animals
{font-style:italic; font-weight:normal;}DD.suborder
{font-weight:bold ; color:blue;}DD
{font-weight:normal; color:black} </STYLE> </HEAD> <BODY> <b style="color:#008000">JURASSIC ANIMALS</b><DL
style="background:#BBEEDD"><DT
class="order">Pterosauria<DD
class="suborder">Rhamphorhynchoidea<DL>
<DT
class="animals">The primitive flyers:<DD>
Eudimorphodon<DD>
Dimorphodon</DL>
<DD
class="suborder">Pterodactyloidea<DL>
<DT
class="animals">Later flying reptiles:<DD>
Pterodactylus<DD>
Pteranodon<DD>
Quetzalcoatlus</DL>
<DT
class="order">Saurischia<DD
class="suborder">Theopodora<DL>
<DT
class="animals">Carnivorous dinosaurs:<DD>
Velociraptor<DD>
TeratoSaurus<DD>
Megalosaurus<DD>
Tyranosaurus</DL>
<DD
class="suborder">Sauropodomorpha<DL>
<DT
class="animals">Herbivorous dinosaurs:<DD>
Brachiosaurus<DD>
Diplodocus<DD>
Apatosaurus (Brontosaurus)</DL>
<DT
class="order">Orthinischia<DD
class="suborder">Ornithopodia<DL>
<DT
class="animals">Bird feet:<DD>
Lesothosaurus<DD>
Hypsilophodont<DD>
Iguanodon</DL>
<DD
class="suborder">Stegosauria<DL>
<DT
class="animals">Bony plated backbone dinosaurs:<DD>
Stegosaurus</DL>
<DD
class="suborder">Ankylosauria<DL>
<DT
class="animals">Armoured dinosaurs:<DD>
Ankylosaurus</DL>
<DD
class="suborder">Ceraptopia<DL>
<DT
class="animals">Horned dinosaurs:<DD>
Triceratops<DD>
Chasmosaurus</DL>
</DL>
</BODY></HTML>
In place of a DD you can put an embedded DL block. The contents of the embedded DL element is further indented. You can use embedded DL elements to create indentation to multiple levels.
2. USAGE
2.1 Simple form
The simple forms of the lists are:Ordered list - with ordering symbols ahead of the lines | |
<OL> | |
Unordered list - with markers ahead of the lines | |
<UL> | |
Definition list - with definition text indented | |
<DL> |
2.2 Embedded list
In place of theLI
or DD
element, an embbed list can be inserted, resulting in structures like these:
DD
block under a DT
element, since the DD
block holds the definition of the term contained in the DT
element. However, there can be more than one DD
under a DT
element, to make the structure resemble the two others. If you wish to strictly abide by logic, in place of a new DD
block, you can just use the BR
element to start the new block.
2.3 Attributes
All the elements have what we call common attributes, in this document. These are:id
attributeclass
attributelang
attributedir
attributestyle
attributetitle
attributecommon event handling
attributes2.4 Style properties
Most widely used in connection with lists are: