HTML XHTML The Complete Reference
home » reference » appendix a » html element reference

<ul> (Unordered List)


This element is used to indicate an unordered list, namely a collection of items that do not have a numerical ordering. The individual items in the list are defined by the <li> element, which is the only allowed element within a <ul> tag.

Standard Syntax


<ul
class="class name(s)"
compact="compact" (transitional only)
dir="ltr | rtl"
id="unique alphanumeric identifier"
lang="language code"
style="style information"
title="advisory text"
type="circle | disc | square" (transitional only)

List items specified by <li> tags
</ul>

Attributes Defined by Internet Explorer


accesskey="key" (5.5)
contenteditable="false | true | inherit" (5.5)
hidefocus="true | false" (5.5)
language="javascript | jscript | vbs | vbscript" (4)
tabindex="number" (5.5)
unselectable="on | off" (5.5)

Standard Event Attributes


onclick, ondblclick, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup

Events Defined by Internet Explorer


onactivate, onbeforeactivate, onbeforecopy, onbeforecut, onbeforedeactivate, onbeforeeditfocus, onbeforepaste, onblur, oncontextmenu, oncontrolselect, oncopy, oncut, ondeactivate, ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, ondrop, onfocus, onfocusin, onfocusout, onhelp, onlosecapture, onmouseenter, onmouseleave, onmousewheel, onmove, onmoveend, onmovestart, onpaste, onpropertychange, onreadystatechange, onresize, onresizeend, onresizestart, onselectstart, ontimeerror

Element Specific Attributes


compact
This attribute indicates that the list should be rendered in a compact style. Few browsers actually change the rendering of the list regardless of the presence of this attribute. The compact attribute requires no value.

type
The type attribute is used to set the bullet style for the list. The values defined under HTML 3.2 and the transitional version of HTML 4.0/4.01 are circle, disc, and square. A user agent might decide to use a different bullet depending on the nesting level of the list unless the type attribute is used. The WebTV interface also supports a triangle bullet. The type attribute is dropped under the strict version of HTML 4.0 because style sheets can provide richer bullet control.

Examples


<ul compact title="Sushi Short List" type="circle">
   <li>Maguro
   <li>Ebi
   <li>Hamachi
</ul>

<!-- Common but bad example -->
<ul>
Indenting using lists should not be used, though it is common.
Many Web editors generate code laden with nonbreaking spaces and
unordered lists.</ul>

Compatibility


HTML 2, 3.2, 4, 4.01, XHTML 1.0, 1.1, Basic
Internet Explorer 2, 3, 4, 5, 5.5, 6
Netscape 1, 2, 3, 4, 4.5-4.8, 6, 7
Opera 4-7

Notes


HTML 2.0 supports only the compact attribute.

The HTML 3.2 specification supports compact and type.

Under the strict HTML and XHTML specifications, the ul element does not support the compact attribute or the type attribute. Both of these attributes can be safely replaced with style rules.

Due to XHTML's deprecation of attribute minimization, the compact attribute must have a quoted attribute when used in the transitional variant: <ul compact="compact"></ul>

Many Web page designers and page development tools use the <ul> tag to indent text. The only element that should occur within a ul element is li, so such markup does not conform to standards. However, this common practice is likely to continue.

Since the content model of ul says list items should be the only item within <ul> tags. Nested lists should occur within <li> tags rather than outside them as they are commonly found.

Style sheets provide much better support for bullet control. See Appendix B or Chapter 10 for more information.

(X)HTML Elements
CSS Properties
Previous: u Next: var
< Home | About | Chapters | Examples | Errata | Reference | Site Map >