WML Tutorial on WML Links

wml provides you an option to link various cards using links and then navigate through different cards.

there are two wml elements, <anchor> and <a>, which can be used to create wml links.

wml <anchor> element:

the <anchor>...</anchor> tag pair is used to create an anchor link. it is used together with other wml elements called <go/>, <refresh> or <prev/>. these elements are called task elements and tell wap browsers what to do when a user selects the anchor link

you can enclose text or image along with a task tag inside <anchor>...</anchor> tag pair.

the <anchor> element supports the following attributes:

attribute value description
title cdata defines a text identifying the link
xml:lang language_code sets the language used in the element
class class data sets a class name for the element.
id element id a unique id for the element.

following is the example showing usage of <anchor> element.

<?xml version="1.0"?>
<!doctype wml public "-//wapforum//dtd wml 1.2//en"
"http://www.wapforum.org/dtd/wml12.dtd">

<wml>

<card title="anchor element">
<p>
   <anchor>
      <go href="nextpage.wml"/>
   </anchor>
</p>
<p>
   <anchor>
      <prev/>
   </anchor>
</p>
</card>

</wml>

this will produce the following result:

wap example 9

wml <a> element:

the <a>...</a> tag pair can also be used to create an anchor link and always a preferred way of creating links.

you can enclose text or image inside <a>...</a> tags.

the <a> element supports the following attributes:

attribute value description
href url defines url of the liked page
title cdata defines a text identifying the link
xml:lang language_code sets the language used in the element
class class data sets a class name for the element.
id element id a unique id for the element.

following is the example showing usage of <a> element.

<?xml version="1.0"?>
<!doctype wml public "-//wapforum//dtd wml 1.2//en"
"http://www.wapforum.org/dtd/wml12.dtd">

<wml>

<card title="a element">
<p> link to next page: 
   <a href="nextpage.wml">next page</a>
</p>
</card>

</wml>

this will produce the following result:

wap example 10