Anchor Links in XHTML MP

Preferences - Do not show ads

Anchor links are used for navigation. You select an anchor link to go to another resource such as an XHTML MP page, or to scroll to a location in the current XHTML MP document. Anchor links are created with the <a></a> tag pair.

The href attribute of the <a> tag is used to specify the URL (Uniform Resource Locator) to the link target. The protocol used is HTTP. A URL has the form:


You should be very familiar with it if you have programmed HTML or WML before.

Going to a Location in the Current XHTML MP Page

As said earlier, you can make use of an anchor link to scroll to a location in the current XHTML MP page. To do this, first you have to set a link destination (target anchor) within the document. Second, you have to point an anchor link to the destination.

To set a link destination within an XHTML MP document, the id attribute should be used. Most XHTML MP tags contain the id attribute. Here are some examples:

<a id="destination_id"></a>

<a id="destination_id" />

<h1 id="destination_id">XHTML MP Tutorial</h1>

<p id="destination_id">Some text in a paragraph</p>

To point an anchor link to the link destination, you need to construct a URL using the id of the link destination as the offset (Note that an offset begins with the # character), and then specify this URL as the href attribute value of the anchor link, like this:

<a href="#destination_id">Select here to go to a location in the current XHTML MP document</a>

As the link destination is in the current XHTML MP document, there is no need to specify the host name, path and file name in the URL. Only the offset is needed.

The following XHTML MP example demonstrates how to go to a location within the current document:


<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "">

<html xmlns="">
    <title>XHTML MP Tutorial</title>

    <p><a id="top">Table of Contents:</a></p>
      <li>Part 1 XHTML MP Introduction</li>
      <li>Part 2 Development of Wireless Markup Languages</li>
      <li>Part 3 Advantages of XHTML MP</li>
      <li>Part 4 WML Features Lost in XHTML MP</li>
    <p><a href="#top">Back to top</a></p>

This is the result of the above XHTML MP example in a mobile phone browser:

Nokia Mobile Browser 4.0

If you select the "Back to top" link, the page will be scrolled to show the text "Table of Contents".

Nokia Mobile Browser 4.0

For Sony Ericsson mobile phones, going to a link destination in the current XHTML MP page is not supported until browser version 4.0, which is first included in Sony Ericsson Z1010 mobile phones. Hence, earlier mobile phone models such as T610 and T68i do not support this feature.

Page 23 of 36 Previous Page | Next Page
Contents at a Glance
Print this Web Page | | Back to Top

Feedback Form (Expand)

What do you think about this web page?

XHTML MP Tutorial Table of Contents XHTML MP Tutorial Contents at a Glance Preferences - Change Color Scheme Preferences - Do Not Show Ads Previous Page Next Page