start page | rating of books | rating of authors | reviews | copyrights

Dynamic HTML: The Definitive Reference, 2rd Ed.Dynamic HTML: The Definitive ReferenceSearch this book

Chapter 8. HTML and XHTML Reference

Contents:

Attribute Value Types
Shared HTML Element Attributes
Alphabetical Tag Reference

This chapter provides a complete list of HTML tags and attributes implemented in Microsoft Internet Explorer and Netscape Navigator, as well as the ones specified in the W3C recommendations for HTML 4.01 and XHTML 1.1. Version information accompanies each tag and attribute so that you can see whether a particular entry applies to the browser(s) you must support. At a glance, you can see the version number of Internet Explorer, Netscape Navigator, and the W3C HTML specification in which the item was first introduced. Because this book deals with Dynamic HTML, the history timeline goes back only to HTML 3.2, Navigator 2, and Internet Explorer 3.

If an item existed prior to one of these versions and is still in use, it is simply marked "all." Where no implementation exists, I've used "n/a" to indicate that. In rare instances, an item has been removed from the HTML specification or a browser family. Such items are marked with a less-than symbol and the version number that no longer supports the item (e.g., NN <6 for prior to Netscape 6). Items valid for a single version show the number encased in pipe symbols (e.g., |4| for Version 4 only). Deprecated items are listed here because modern browsers support them for backward compatibility, and legacy code may rely on them. Text references to Netscape 6 automatically imply support for all Mozilla-based browsers, including Netscape 7.

A handful of items that appear as new for Version 6 browsers may not, in truth, be fully implemented in these browsers. This occurs when a browser maker claims support for an element or attribute because the item is implemented in HTML 4, and the browser wishes to claim compliance with that standard version. The descriptions of such items clearly state when the item is valid but not connected.

Following a section that lists attributes shared by all elements, this chapter is organized alphabetically by HTML element (or tag, if you prefer); within each element's description, attributes are listed alphabetically and displayed in a grey font. The reference entries are designed so that it is easy to see which elements require end tags (in HTML), and whether attributes are optional or required. Scripted object references are displayed in the W3C DOM standard syntax style unless the item requires a different DOM style (e.g., the Navigator 4 layer element). Although the W3C DOM document.getElementById( ) syntax prevails in the listings, if IE supports the item through its DOM scripting, you can assume that the document.all reference style also applies in that environment. The description for an item details any significant differences between the various browser implementations of the item.

All example code is formatted according to W3C HTML standards because the widest number of DHTML browsers support that format and all readers will be familiar with it. At the same time, however, the code demonstrates most practices encouraged for XHTML formatting, such as lowercase tag and attribute names and quoted attribute values of all types. The only XHTML formatting characteristics lacking from the example code are end tags for empty elements (such as the XHTML backward-compatible <br /> technique) and explicit value assignments to attributes that do not require them in HTML (such as the selected attribute of checkbox type input elements). These coding style variations are easy to modify on your own if your code must conform to XHTML validation (see Chapter 1).

For in-depth coverage of event types related to event attributes mentioned in this chapter, see Chapter 10. To find out which, if any, HTML and XHTML DTDs support a particular element or attribute, consult Appendix E.

8.1. Attribute Value Types

Many HTML element attributes share similar data requirements. For the sake of brevity in the reference listings, this section describes a few common attribute value types in more detail than is possible within each listing. Whenever you see one of these attribute value types associated with an attribute, consult this section for a description of the type.

8.1.1. Length

A length value defines a linear measure of document real estate, such as the width of a table element. The unit of measurement can be any applicable unit that helps identify a position or space on the screen. HTML attribute length units are uniformly pixels, but in other content, such as that specified in Cascading Style Sheets (see Chapter 11), measurements can be in inches, picas, ems, or other relevant units. A single numeric value may represent a length when it defines the offset from an edge of an element. For example, a coordinate point (10,20) consists of two length values, denoting pixel measurements from the left and top edges of an element, respectively. Attributes associated with length values are deprecated in favor of corresponding CSS attributes for strict HTML 4 and XHTML conformance.

8.1.2. Identifier

An identifier (usually assigned to name or id attributes) is a name that adheres to some strict syntactical rules. Most importantly, an identifier is one word with no whitespace allowed. If you need to use multiple words to describe an item, you can use the inter-capitalized format (in which internal letters are capitalized) or an underscore character between the words. Most punctuation symbols are not permitted, but all numerals and alphabetical characters are. To avoid potential conflicts with scripting languages that refer to items by their identifiers, it is good practice to avoid using a numeral for the first character of an identifier.

8.1.3. URI and URL

The term Universal Resource Identifier (URI) is a broad term for an address of content on the Web. A Universal Resource Locator (URL) is a type of URI. For most web authoring, you can think of them as one and the same because most web browsers restrict their focus to URLs. A URL, commonly applied to href and src attributes, may be complete (including the protocol, host, domain, and the rest) or may be relative to the URL of the current document. The latter case means the URL may consist of an anchor, file, or pathname. In scriptable browsers, attributes that expect URI values can also accept the javascript: pseudo-protocol, which makes a script statement or function the destination of the link. This pseudo-protocol, while implemented widely, is not a formal standard.

8.1.4. Language Code

There is an extensive list of standard codes that identify the spoken and written languages of the world. A language code always contains a primary language code, such as "en" for English or "zh" for Chinese. Common two-letter primary codes are cataloged in ISO-639 (an excerpted list of codes is available at http://www.ietf.org/rfc/rfc1766.txt). An optional subcode (separated from the primary code by a hyphen) may be used to identify a specific implementation of the primary language, usually according to usage within a specific country. Therefore, although "en" means English, "en-US" means a U.S.-specific version of English. The browser must support a particular language code for its meaning to be of any value to an element attribute.

8.1.5. Alignment Constants

The frequent presence of the align attribute among various elements (and the related but less pervasive valign attribute) is misleading when describing attribute values, because the attribute conveys different meanings for several element groups. Add to the mix several proprietary values that are implemented in some browsers, and it's easy to confuse which values to use when. That all such attributes are deprecated in favor of the CSS text-align (horizontal) and vertical-align attributes is welcome relief to authors who develop for browsers that support CSS.

Element alignment is divisible into five categories, each with its own set of applicable elements and permissible values. Browsers accept case-insensitive values, but if you intend to continue working with these attributes, you should get in the habit of using all lowercase values to conform with the transitional DTDs.

8.1.5.1. Alignment outside the box

The first category governs the alignment of text that surrounds the rectangular space of the element bearing the align attribute. W3C HTML elements in this category include applet, iframe, img, input, and object. IE adds embed, fieldset, and select elements to the list, while deleting iframe. Here is a synopsis of the various align attribute settings for these elements and how they affect the display of the element and surrounding text content:

absbottom
Text is aligned such that the bottom of any possible text rendering (including character descenders) is on the same horizontal line as the very bottom of the element. For IE 4 and later and Navigator 4 only; Netscape 6 equates this attribute with W3C bottom.

absmiddle
The middle of the text height (from descender to ascender) is aligned with the middle of the element height. For IE 4 and later and Navigator 4 only; Netscape 6 equates it with middle.

baseline
The baseline of the text is on the same horizontal line as the very bottom of the element (note that character descenders extend below the baseline). This is for IE and Navigator, but is not a W3C-sanctioned value.

bottom
The W3C sanctioned value that is the equivalent of baseline.

left
If there is text starting on the same line as the element, the element is lowered to the next line and displayed flush left within the next outermost container context. Text that follows the element cinches up to the end of the text preceding the element, causing the text to wrap around the object or image (called floating). This is a W3C-sanctioned value.

middle
The baseline of the text is aligned with the middle of the element height. This is a W3C-sanctioned value.

right
If there is text starting on the same line as the element, the element is lowered to the next line and displayed flush right within the next outermost container context. Text that follows the element starts on the line immediately below the starting text, causing the text to wrap around the object or image (called floating). This is a W3C-sanctioned value.

texttop
The very top of the element is on the same horizontal line as the ascenders of the preceding text. This attribute is for IE and Navigator, but is not a W3C-sanctioned value.

top
The top of the element is on the same horizontal line as the top of the tallest element (text or other kind of element) rendered in the line. This is a W3C-sanctioned value.

8.1.5.4. Horizontal text alignment in a table cell

In the W3C specification, text inside descendant nodes of the table element (tbody, tr, td, and the rest) can be aligned according to the values center, justify, left, and right. IE, however, does not recognize the justify value for table components. If you wish to justify text in an IE table cell, wrap the text in a p or div container, and set that container's align attribute to justify.

8.1.6. Colors

A color value can be assigned either via a hexadecimal triplet or with a plain-language equivalent. A hexadecimal triplet consists of three pairs of hexadecimal (base 16) numbers that range between the values 00 and FF, corresponding to the red, green, and blue components of the color. The three pairs of numbers are bunched together and preceded by a pound sign (#). Therefore, the reddest of reds has all red (FF) and none (00) of the other two colors: #FF0000; pure blue is #0000FF. The letters A through F can also be lowercase.

This numbering scheme creates a huge number of potential combinations (over 16 million), but not all video monitors are set to distinguish among millions of colors. Therefore, you may wish to limit yourself to the more modest palette of colors known as the web palette. A fine reference of colors that work well on all browsers at popular bit-depth settings can be found at http://www.lynda.com/hexh.html.

The HTML recommendation also specifies a basic library of 16 colors that can be assigned by plain-language names. Note that the color names are case-insensitive. The names and their equivalent hexadecimal triplets are as follows:

Black #000000 Maroon #800000 Green #008000 Navy #000080
Silverd #C0C0C0 Red #FF0000 Lime #00FF00 Blue #0000FF
Gray #808080 Purple #800080 Olive #808000 Teal #008080
White #FFFFFF Fuchsia #FF00FF Yellow #FFFF00 Aqua #00FFFF

In other words, the attribute settings bgcolor="Aqua" and bgcolor="#00FFFF" yield the same results.

Netscape developed a much longer list of plain-language color equivalents. These are detailed in Appendix A, and are recognized by recent versions of both Navigator and Internet Explorer.



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.