If
you’ve done much work
with HTML, the <anchor>
element may seem
like a lot of typing. Sure, it’s more flexible than
HTML’s <A>
tag, but it seems much
nicer to simply type:
<A HREF="somewhere">linked text</A>
than it is to type:
<anchor><go href="somewhere"/>linked text</anchor>
Fear not: the designers of WML also recognized this fact and provided
WML with the <a>
element. (The name must be
a lowercase a
.) It’s a useful shorthand for
this simple case of the <anchor>
element,
which also has the benefit of looking familiar to HTML developers. It
takes two attributes:
-
title
(optional variable string) This has exactly the same effect as the
title
attribute on the<anchor>
element. It provides an optional title for the element, which some browsers may use in displaying it. The same caveats apply: it’s wise to keep the length to at most six characters, and the browser is free to ignore the attribute (as indeed most do).-
href
(required variable URL) Specifies the URL to go to when the link is activated.
For example, the element:
<a title="Next" href="page17.wml">Next Page</a>
is exactly equivalent to:
<anchor title="Next"> <go href="page17.wml"/> Next Page </anchor>
The form using the <a>
element is also more
efficient than the form using <anchor>
, as
there is less to transmit to the browser. Try to use the
<a>
form wherever possible.
Get Learning WML, and WMLScript now with O’Reilly online learning.
O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.