Lists

HTML supports various types of list structure. In all cases, an element that expresses the type of list is used to enclose a number of others, each representing one item in the list.

The most basic type of list is the Ul (unordered list):

					<UL>
...
</UL>
				

An unordered list is used when the items do not form a logical sequence or series of steps. It contains a number of Li (list item) elements. Each of these contains text, and is automatically preceded by a bullet, dash or other symbol:

<UL>
<LI>First Item</LI>
					<LI>Second Item</LI>
					<LI>Third Item</LI>
</UL>

  • First Item

  • Second Item

  • Third Item

The deprecated Dir (directory list) element is intended to hold directory listings, which are very short items that may be formatted in columns (as in UNIX file listings):

					<DIR>
<LI>MYBOOK.DTD</LI>
<LI>MYBOOK.XML</LI>
<LI>PARSER.EXE</LI>
<LI>REPORT.DAT</LI>
</DIR>


   MYBOOK.DTD   PARSER.EXE
   MYBOOK.XML   REPORT.DAT

The deprecated Menu list is intended to be used to represent software menu selections. The content of each item is assumed to be short, and the browser is likely to indent them and omit the bullet:

					<MENU>
<LI>Activate</LI>
<LI>Options</LI>
<LI>Help</LI>
<LI>Exit</LI>
</MENU>


      Activate
      Options
      Help
      Exit

The Ol element (ordered list) is similar to the unordered list, but each item is preceded by a sequential, automatically generated number. It is used in preference to the Ul element when the items describe a series of steps, or are referred to individually elsewhere:

					<OL>
<LI>Step 1</LI>
<LI>Step 2</LI>
<LI>Step 3 - Go To Step 1</LI>
</OL>
				

1. Step 1

2. Step 2

3. Step 3 - Go To Step 1

A Type attribute is available on the Ol, Ul and Li elements (but is now deprecated in the first two cases). An ordered list can take Type values of 'A' (capital letters), 'a' (small letters), 'I' (large Roman letters), 'i' (small Roman letters) or '1' (digits), which is the default. An unordered list can take Type values of 'DISC' (bullet), 'CIRCLE' (hollow bullet) or 'SQUARE' (a square hollow bullet). The list item can take the same values, depending which list type it is within, and overrides the current setting for the list within all remaining items. In addition, the ordered list has a Start attribute, which indicates a start value for the first item when it is not '1' (or equivalent), and the list item has a Value attribute that can only be used within ordered lists to reset the current calculated value:

<OL TYPE="A" START="4">
   <LI>First Item
   <LI VALUE="G">Second Item
   <LI>Third Item
</OL>

D First Item

G Second Item

H Third Item

Some lists consist of a keyword or term, followed by an explanation of that keyword or term. The Dl (definition list) element contains a number of items (but not Item elements), each one consisting of two parts, a Dt (definition term) element and a (Dd) (definition details) element:

<DL>
<DT>HTML<dd>HyperText Markup Language
<DT>DTD<dd>Document Type Definition
<DT>XML<dd>Extensible Markup Language
</DL>

HTML HyperText Markup Language

DTD Document Type Definition

XML Extensible Markup Language

All of the list types described above may be condensed by closing the gap between items, using the Compact attribute (now deprecated in all but the Dl element). This implied attribute has a single value option of 'compact', and the attribute name does not appear:

<UL COMPACT>

HTML has inherited this minimization feature from SGML, and it is not available in XML (though the XSLT processor should be able to output this minimized structure).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset