Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

HTML 4.0 Sourcebook
(Publisher: John Wiley & Sons, Inc.)
Author(s): Ian S. Graham
ISBN: 0471257249
Publication Date: 04/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


UL defines an unordered list of items; a graphical browser will present each list item with a special leading symbol, such as a bullet or asterisk. Each item in a UL list is contained within an LI (list item) element—LI elements are the only things that can appear inside a UL. Items can be paragraphs of text, but should be kept reasonably short; otherwise, the idea of a list is lost. If the list items are big, perhaps it is not really a list: Try paragraphs with appropriate section headings.

The UL element can take two optional attributes, namely:

COMPACT (optional) Requests that the list be presented in a compact way, for example, by reducing whitespace between list entries. This attribute is not widely supported.
TYPE=“circle,” “disc,” “square” (optional) Specifies the desired type of bulleting symbol. The allowed values are TYPE=“disc” (for a small circular disc), TYPE=“circle” (for a small open circle), or TYPE=“square” (for a small square). The default value varies, depending on the level of the list: Most browsers use different symbols for list items nested inside other list items.

Figures 6.27 to 6.30 show examples of unordered lists.


Figure 6.27 HTML example document illustrating UL and OL lists and the nesting of list elements. Figure 6.28 shows this document as displayed by the Internet Explorer browser.

<HTML>
<HEAD>
<TITLE> Example of Regular List elements </TITLE>
</HEAD>
<BODY>
<H2> Examples of Regular Lists </H2>
<H3> Ordered Lists </H3>
<P>This shows an ordered list, with another ordered list nested
   within it.
<OL>
  <LI>First item -- items can contain images, blockquotes, and
      other lists, among other things
  <LI>A Second item in the list
  <LI VALUE=“6”>And a third item (but a <B>VALUE</B> attribute sets it
  to numeral 6). And now.... a nested ordered list, with the type
  attribute <B>TYPE</B>=“i”:
      <OL TYPE=“i” START=“2”>
	 <LI>The first sub-item
	 <LI>The second sub-item, and so on.....
      </OL>
</OL>
<H3> Unordered Lists </H3>
<P>This examples illustrates and unordered list containing another
unordered list.
<UL>
   <LI>A list item
   <LI>Another list item; again these can contain IMG elements,
       paragraphs, and so on
   <LI>List items can also contain lists, for example:
       <UL>
	<LI TYPE=“circle”>An item in the list
	<LI TYPE=“square”>Something else that is
	    important, and so on
       </UL>
       Which is simply a list within a list
</UL>
</BODY> </HTML>


Figure 6.28   Display, by the Internet Explorer 3 browser, of the document shown in Figure 6.27.

DIR Element: Directory List

Usage: <DIR> ... </DIR>
Can Contain: LI
Can Be Inside: BLOCKQUOTE, BODY, CENTER, DD, DIV, FIELDSET, FORM, LI, NOFRAMES, NOSCRIPT, TD, TH,
APPLET, BUTTON, IFRAME, OBJECT
Attributes: CLASS, DIR, ID, LANG, STYLE, TITLE, standard event handlers,
COMPACT


NOTE: DIR To Be Dropped from HTML—Use UL Instead

The DIR element is to be dropped from HTML, as similar formatting is possible using the UL element. You should thus avoid DIR in new documents, in favor of UL lists.


DIR defines a directory list—a list of short items, each usually no more than about 20 characters. If possible, a browser may display the items in columns across the screen, rather than one above the other (most browsers do not do this, however, and format DIR and UL lists identically). Each item in a DIR list is contained within an LI (list item) element—LI elements are the only things that can appear inside a DIR list. An example of a directory list is shown in Figures 6.29 and 6.30.

MENU Element: Menu List

Usage: <MENU> ... </MENU>
Can Contain: LI
Can Be Inside: BLOCKQUOTE, BODY, CENTER, DD, DIV, FIELDSET, FORM, LI, NOFRAMES, NOSCRIPT, TD, TH,
APPLET, BUTTON, IFRAME, OBJECT
Attributes: CLASS, DIR, ID, LANG, STYLE, TITLE, standard event handlers,
COMPACT


NOTE: MENU To Be Dropped from HTML—Use UL Instead

The MENU element is to be dropped from HTML, as similar formatting is possible using the UL element. You should thus avoid MENU in new documents, in favor of UL lists.


MENU defines a list of short menu items, each item preferably less than a sentence long. MENU is designed to work like UL but to be formatted in a more compact manner similar to a <UL COMPACT> list, except that formatting may be optimized to favor short list items (most browsers do not do this, however, and format MENU and UL lists identically). Each item in a MENU list is contained within an LI (list item) element—LI elements are the only things that can appear inside a MENU list. Figures 6.29 and 6.30 give an example of a MENU list.


Figure 6.29 HTML example document illustrating the MENU and DIR lists. Figure 6.30 shows this document as displayed by the Netscape Navigator browser.

<HTML><HEAD>
<TITLE> More Examples of Regular Lists </TITLE>
</HEAD>
<BODY>
<H2 ALIGN=“center”> Lists, Lists and Yet More Lists </H2>

<H3> Regular UL Lists </H3>
<UL>
   <LI>A list item.
   <LI>another list item
   <LI>and still more items
   <LI>What ... still more?
</UL>
<HR SIZE=“5” WIDTH=“20%”>
<H3> DIR Lists </H3>
<DIR>
   <LI>Abraham - Carbon
   <LI>Cardshark - Elegant
   <LI>Elegiac - Food
   <LI>Foot - Hogs
</DIR>
<HR SIZE=5 WIDTH=“20%”>
<H3> MENU Lists </H3>
<MENU>
   <LI>First item   <LI>Second item
   <LI>Third item   <LI>Fourth item
</MENU>
</BODY></HTML>


Figure 6.30  Display of the document shown in Figure 6.29 by the Netscape Navigator 3 browser. Note how the UL, MENU, and DIR lists are rendered in the same way. Very few browsers distinguish between these three list types. MENU and DIR are deprecated elements and shoud not be used in new documents.

LI Element: List Item

Usage: <LI> ... (</LI>)
Can Contain: ADDRESS, BLOCKQUOTE, CENTER, DIR, DIV, DL, FIELDSET, FORM, Hn, HR, [ISINDEX], MENU, NOFRAMES, NOSCRIPT, OL, P, PRE, TABLE, UL,
characters, character highlighting, A, APPLET, BASEFONT, BR, BUTTON, IFRAME, IMG, INPUT, LABEL, MAP, OBJECT, SCRIPT, SELECT, TEXTAREA
Can Be inside: DIR, MENU, OL, UL
Attributes: CLASS, DIR, ID, LANG, STYLE, TITLE, standard event handlers,
TYPE, VALUE

LI marks a list item within DIR, MENU, OL, or UL lists. The item can contain text, character markup, and hypertext anchors, as well as subsidiary lists and text blocks.

LI supports two attributes for defining the type of the bullets in unordered lists, and for controlling numbering in ordered lists. These are:

TYPE=“disc,” “circle,” “square” (within UL unordered lists), or “I,” “i,” “A,” “a,” “1” (within OL ordered lists) Defines the type of marker to use with the item. Within unordered lists, the values “disc,” “circle,” and “square” produce closed discs, open circles, and squares respectively. In ordered lists, “I” and “i” produced uppercase and lowercase roman numerals respectively; “A” and “a” produce upper- and lowercase alphabetized lists respectively; and “1” produces numbered lists. Note that selecting a TYPE for a list item sets this type for all subsequent list items, unless another TYPE attribute is present.


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.