WML is a generalized markup language that is optimized for
limited capability devices and networks. WML documents are an XML
document type. It has also borrowed from HDML 2.0 (Phone.com's
proprietary markup language) and HTML. It is case sensitive.
WML is based on a deck of cards metaphor, in which
a document is analogous to a deck, and a card is approximately
analogous to an individual screen or unit of display. The unit of
transmission between the gateway and the mobile device is the deck,
and the unit of user interaction is a card within the deck. This
structure is illustrated in the diagram below:

Rather than focusing on the details of the rendering of UI
elements, or of how the user should interact with the browser, WML
focuses on the semantic meaning of the element. Separating the
rendering from the meaning allows the actual rendering and
implementation on the device to be adapted to the capabilities of
the device.
WML elements support a number of features including text and
images, the ability to interact with the user, navigation
capabilities and variables. Layout and presentation hints can be
included with text and images, but it is ultimately up to the
browser how it renders the content. Templates can be used to
specify a set of characteristics that apply to all cards in the
deck. Examples of WML are given in the next section.
User interaction is facilitated in the form of entering text or
selecting options or actions, which trigger events.
Navigation between cards within the deck is supported, as well
as between decks. Navigation is either through URL hyperlinks or
through a history stack. A URL is taken to reference the first card
in a deck, although other cards within the deck can be referenced
using fragment anchors. Relative URLs are supported. A history of
URLs is maintained in a stack that supports typical stack-like
functions (push, pop and reset).
WML supports navigation in both a forward and backward direction
through triggering of events. The onenterforward event causes the
browser to go to the associated URL if the card is entered in the
forward direction, using the <go> element or a semantically
equivalent element. The URL of the current card is placed on the
history stack and can be returned to by using backward navigation.
The onenterbackward event performs a similar function when the card
is entered from the backwards direction, using the <prev>
element or a semantically equivalent element. The ontimer event
will cause a jump to the associated URL when a timer expires. The
onpick event is triggered when an item is selected from a list.
The actions to be performed in response to events and user
interactions are specified in terms of tasks. The <go>
element indicates navigation to a URI and pushes the current URI
onto the history stack. An HTTP submission method of post or get
can be specified as well as the variables that are to be
transmitted to the server as part of the URI request. Backward
navigation through the history stack is specified with the
<prev> element. With either a <go> or <prev> a
variable value can be set. The <refresh> element is used to
cause the display to be refreshed with the value of variables that
have changed since the last display. The <noop> element
causes nothing to happen and is used to override deck level
elements in a card.
Tasks need to be bound to events so that the tasks execute when
the event is triggered. The <do> element specifies a user
interface element that the user can directly interact with to
trigger the event. The rendering of the UI element is up to the
browser, although a hint is given as to the semantic meaning of the
element through the type attribute. The <do> element can
occur at either the card or deck level, and may be designated as
optional.
The <onevent> element is specified within an enclosing
element and is used to bind a task to an intrinsic event for the
enclosing element. For example, an <onevent> element enclosed
within a <card> element, with a type of onenterforward and
which encloses a <go> element, will bind the <go>
element to the onenterforward event for that card. When someone
enters that card in the forward direction the <go> will be
triggered and the URL specified in the href attribute of the
<go> element will be loaded.
The WML browser maintains a context that can contain variables.
Variable names are case sensitive and are preceded by a $.
Parameterized cards and variable substitution allows for the
contents of the card to be customized on the phone, but variables
cannot be substituted for elements or attributes. Variables can be
shared between cards and decks. The value of a variable is set by a
<setvar> element, an <input> element or a
<select> element. A <postfield> element can be used to
transmit the contents of a variable to the server during a URL
request.
User input is facilitated through the <input> and
<select> elements. The <input> element specifies a text
entry object. As before, the form and rendering of the object
depends on the browser. A default value can be specified, and the
length of the object, the maximum size of the text entered and
formatting options can also be specified. Empty strings can be
refused and password masks can be applied to the input. The
<select> element indicates a choice from a list of options.
Options can be grouped to form hierarchies, and both single and
multiple-choice lists are supported. A default can also be
specified for use in the event that the user does not make a
selection.
Links are specified with either the <anchor> element or
the <a> element, which is a short form of <anchor>. The
element specifies the head of the link - the tail is always
specified by another element. Anchors must have an associated task.
The link can specify an image that is to be included in the
document. It can include some alternate text to be used if the
image cannot be displayed, and it can also have dimensions and
alignment specified.
The <timer> element is used to set the value of a timer on
entry to a card. The time is specified in tenths of a second and
the ontimer event will be triggered when the timer reaches 0.
Tables are supported through the <table>, <tr> and
<td> elements. The number of columns in the table is
specified as an attribute of the <table> element. The
<tr> element contains a row of the table, and the <td>
element contains a cell within the table.