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

HTML: The Definitive Guide

Previous Chapter 4
Text Basics
Next
 

4.9 Addresses

Addresses are a very common element in text documents, and HTML provides a special tag that sets addresses apart from the rest of a document's text. While this may seem a bit extravagant--addresses have few formatting peculiarities that would require a special tag--it is an example of content, not format, that is the intent and purpose of HTML markup.

By defining text that comprises an address, the author lets the browser format that text in a different manner, as well as process that text in ways helpful to users. It also makes the content readily accessible to automated readers and extractors. For instance, an online directory might include addresses the browser collects into a separate document or table, or automated tools might extract addresses from a collection of documents to build a separate database of addresses.

The <address> Tag

The <address> and its required end (</address>) tag tell a browser that the enclosed text is an address. The browser may format the text in a different manner than the rest of the document text, or use the address in some special way. You also have control over the display properties through the style and class attributes for the tag (see Chapter 9, Cascading Style Sheets).

The text within the <address> tag may contain any element normally found in the body of an HTML document, excluding another <address> tag. Style changes are allowed, but may conflict with the style chosen by the browser to render the address element.

We think most, if not all, HTML documents should have their authors' addresses included somewhere convenient to the user, usually at the end. At the very least, the address should be the author's or webmaster's email address, along with a link to their home page. Street addresses and phone numbers are optional; personal ones are usually not included for reasons of privacy.

For example, the address for the webmaster responsible for a collection of commercial web documents often appears in source documents as follows, including the special mailto: URL protocol that lets users activate the browser's email tool:

<address>
  <a href="mailto:[email protected]">Webmaster</a><br>
  O'Reilly & Associates, Inc.<br>
  Cambridge, Massachusetts<br>
</address>

Figure 4.24 displays the results.

Whether it is short and sweet or long and complete, make sure every document you create has an address attached to it. If something is worth creating and putting on the Web, it is worth comment and query by your readership. Anonymous documents carry little credibility on the Web.

The style and class attributes

Although the browsers usually display <address> content in a defined style, you can override that style and add special effects, such as a background picture, by defining your own style for the tag. This new look can be applied to the <address> tags using either the style or class attributes. [the section called "Inline Styles: The style Attribute"] [the section called "Style Classes"].


Previous Home Next
Block Quotes Book Index Special Character Encoding

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell