11. XHTML Client-Side Image Map Module

Contents

This section is normative.

The Client-side Image Map Module provides elements for client side image maps. It requires that the Image Map Attribute Collection and the Embedding Attribute Collection (or the Object Module) be included. The Client-side Image Map Module supports the following elements:

Elements Attributes Minimal Content Model
area Common, Map, alt* (Text), nohref ("nohref") EMPTY
map I18N, Events, Edit, Embedding, Bi-directional, class (ClassName), id* (ID), title (Text) ((Heading | Block) | area)+

When this module is used, the map element is added to the Inline content set of the Text Module.

Implementation: DTD

11.1. The area element

The area element defines a geometric region associated with an image map, and optionally associates that region with events or external references.

Attributes

The Common collection
A collection of other attribute collections, including: Core, Events, I18N, Bi-directional, Edit, Embedding, and Hypertext
The Map collection
A collection of attributes related to image map, including usemap, ismap, shape and coords.
alt = Text
For user agents that cannot display images, forms, or applets, this attribute specifies alternate text. The language of the alternate text is specified by the xml:lang attribute.

Several non-textual elements let authors specify alternate text to serve as content when the element cannot be rendered normally. Specifying alternate text assists users without graphic display terminals, users whose browsers don't support forms, visually impaired users, those who use speech synthesizers, those who have configured their graphical user agents not to display images, etc.

While alternate text may be very helpful, it must be handled with care. Authors should observe the following guidelines:

  • Do not specify irrelevant alternate text when including images intended to format a page, for instance, alt="red ball" would be inappropriate for an image that adds a red ball for decorating a heading or paragraph. In such cases, the alternate text should be the empty string (""). Authors are in any case advised to avoid using images to format pages; style sheets should be used instead.
  • Do not specify meaningless alternate text (e.g., "dummy text"). Not only will this frustrate users, it will slow down user agents that must convert text to speech or braille output.
nohref = "nohref"
When set, this boolean attribute specifies that a region has no associated link.

11.2. The map element

The map element specifies a client-side image map (or other navigation mechanism) that may be associated with another object. An image map is associated with an element via the element's usemap attribute. The map element may be used without an associated image for general navigation mechanisms.

Attributes

The I18N collection
A collection of attributes related to Internationalization, including the xml:lang.
The Events collection
A collection of user interface-related event attributes defined in the [XMLEVENTS] specification.
The Edit collection
A collection of attributes related to edit, including edit, datetime and cite.
The Embedding collection
A collection of attributes related to embedding content, including src and type.
The Bi-directional collection
A collection of attributes related to bidirectionality, including the dir.
class = ClassName
This attribute assigns one or more class names to an element; the element may be said to belong to these classes. A class name may be shared by several element instances.

The class attribute can be used for different purposes in XHTML, for instance as a style sheet selector (when an author wishes to assign style information to a set of elements), and for general purpose processing by user agents.

For instance in the following example, the p element is used in conjunction with the class attribute to identify a particular type of paragraph.

<p class="note">
These programs are only available if you have purchased
the advanced professional suite.
</p>

Style sheet rules can then be used to render the paragraph appropriately, for instance by putting a border around it, giving it a different background colour, or where necessary by not displaying it at all.

id = ID
The id attribute assigns an identifier to an element. The id of an element must be unique within a document.

The id attribute has several roles in XHTML:

  • As a style sheet selector.
  • As a target anchor for hypertext links.
  • As a means to reference a particular element from a script.
  • As the name of a declared object element.
  • For general purpose processing by user agents (e.g. for identifying fields when extracting data from XHTML pages into a database, translating XHTML documents into other formats, etc.).

As an example, the following headings are distinguished by their id values:

<h id="introduction">Introduction</h>
<p>...</p>
<h id="events">The Events Module</h>
<p>...</p>
title = Text
This attribute offers advisory information about the element for which it is set.

Values of the title attribute may be rendered by user agents in a variety of ways. For instance, visual browsers should display the title as a "tool tip" (a short message that appears when the pointing device pauses over an object). Audio user agents may speak the title information in a similar context.

Example of the use of title:

<a href="/Jakob/" title="Author biography">Jakob Nielsen</a>'s
Alertbox for January 11, 1998

The title attribute has an additional role when used with the link element to designate an external style sheet. See the section on links and style sheets for details.

The presence of the usemapattribute for an object implies that the object being included is an image. Furthermore , when the object element has an associated client-side image map, user agents may implement user interaction with the object solely in terms of the client-side image map. This allows user agents (such as an audio browser or robot) to interact with the object without having to process it; the user agent may even elect not to retrieve (or process) the object. When an object has an associated image map, authors should not expect that the object will be retrieved or processed by every user agent.

The map element content model allows authors to combine the following:

  1. One or more area elements. These elements have no content but specify the geometric regions of the image map and the link associated with each region. Note that user agents do not generally render area elements. Therefore, authors must provide alternate text for each area with the alt attribute.
  2. Block-level content. This content should include a elements that specify the geometric regions of the image map and the link associated with each region. Note that the user agent should render block-level content of a map element. Authors should use this method to create more accessible documents.

When a map element contains mixed content (both area elements and block-level content), user agents must ignore the area elements.

Authors should specify an image maps's geometry completely with area elements, or completely with a elements, or completely with both if content is mixed. Authors may wish to mix content so that older user agents will handle map geometries specified by area elements and new user agents will take advantage of richer block content.

If two or more defined regions overlap, the region-defining element that appears earliest in the document takes precedence (i.e., responds to user input).

User agents and authors should offer textual alternates to graphical image maps for cases when graphics are not available or the user cannot access them. For example, user agents may use alt text to create textual links in place of a graphical image map. Such links may be activated in a variety of ways (keyboard, voice activation, etc.).

11.2.1. Client-side image map examples

In the following example, we create a client-side image map for the object element. We do not want to render the image map's contents when the object is rendered, so we "hide" the map element within the object element's content. Consequently, the map element's contents will only be rendered if the object cannot be rendered.

<html xmlns="http://www.w3.org/2002/06/xhtml2">
  <head>
    <title>The cool site!</title>
  </head> 
  <body>
    <p src="navbar1.png" type="image/png" usemap="#map1"> 
      <map id="map1">
        <nl>
          <label>Navigate the site:</label>
          <li href="guide.html" shape="rect" coords="0,0,118,28">
          Access Guide</li> 
          <li href="shortcut.html" shape="rect" coords="118,0,184,28">
          Go</li> 
          <li href="search.html" shape="circle" coords="184,200,60">
          Search</li>
          <li href="top10.html" shape="poly" coords="276,0,276,28,100,200,50,50,276,0">
          Top Ten</li>
        </nl>
      </map> 
    </p>
  </body>
</html> 

We may want to render the image map's contents even when a user agent can render the object. For instance, we may want to associate an image map with an object element and include a text navigation bar at the bottom of the page. To do so, we define the map element outside the object:

<html xmlns="http://www.w3.org/2002/06/xhtml2">
  <head>
    <title>The cool site!</title>
  </head>
  <body>
    <p src="navbar1.gif" type="image/gif" usemap="#map1">

      ...the rest of the page here...

      <map id="map1">
        <p>Navigate the site: <a href="guide.html"
        shape="rect" coords="0,0,118,28">Access
        Guide</a> | <a href="shortcut.html" shape="rect"
        coords="118,0,184,28">Go</a> | <a href="search.html"
        shape="circle" coords="184,200,60">Search</a>
        | <a href="top10.html" shape="poly"
        coords="276,0,276,28,100,200,50,50,276,0">Top Ten</a>
      </map>
    </p>
  </body>
</html>

In the following example, we create a similar image map, this time using the area element. Note the use of alt text:

<p><object data="navbar1.gif" type="image/gif" usemap="#map1">
  <p>This is a navigation bar.<p>
</object></p> 

<map id="map1">
  <area href="guide.html"
        alt="Access Guide" shape="rect" coords="0,0,118,28"/>
  <area href="search.html"
        alt="Search" shape="rect" coords="184,0,276,28"/>
  <area href="shortcut.html"
        alt="Go" shape="circle" coords="184,200,60"/>
  <area href="top10.html"
        alt="Top Ten" shape="poly"
        coords="276,0,276,28,100,200,50,50,276,0"/>
</map>

The following example illustrates how image maps may be shared.

Nested object elements are useful for providing fallbacks in case a user agent doesn't support certain formats. For example:

<p><object data="navbar.png" type="image/png">
  <object data="navbar.gif" type="image/gif">
    text describing the image...
  </object>
</object></p>

If the user agent doesn't support the PNG format, it tries to render the GIF image. If it doesn't support GIF (e.g., it's a speech-based user agent), it defaults to the text description provided as the content of the inner object element. When object elements are nested this way, authors may share image maps among them:

<p><object data="navbar.png" type="image/png" usemap="#map1">
  <object data="navbar.gif" type="image/gif" usemap="#map1">
    <map id="map1">
      <p>Navigate the site:
      <a href="guide.html" shape="rect" coords="0,0,118,28">Access
      Guide</a> | <a href="shortcut.html" shape="rect"
      coords="118,0,184,28">Go</a> | <a href="search.html"
      shape="circle" coords="184,200,60">Search</a>
      | <a href="top10.html" shape="poly"
      coords="276,0,276,28,100,200,50,50,276,0">Top Ten</a></p>
    </map>
  </object>
</object></p>

The following example illustrates how anchors may be specified to create inactive zones within an image map. The first anchor specifies a small circular region with no associated link. The second anchor specifies a larger circular region with the same center coordinates. Combined, the two form a ring whose center is inactive and whose rim is active. The order of the anchor definitions is important, since the smaller circle must override the larger circle.

<map id="map1">
  <p><a shape="circle" coords="100,200,50">I'm inactive.</a>
  <a href="outer-ring-link.html" shape="circle" coords="100,200,250">I'm
  active.</a></p>
</map>

Similarly, the nohref attribute for the area element declares that geometric region has no associated link.