Wireless Markup Language (WML) Tutorial

Getting Started

WML Cards

The content of the page is placed between wml tags within the document. WAP sites consist of cards rather than pages. Each card represents the text that will be displayed on the device's screen. Not surprisingly, a collection of cards is referred to as a deck. A single document may contain one or more cards. Each card should contain an id attribute, and a title attribute. The id attribute is used for linking, and the title attribute will be displayed as the title on the device's screen. The following example defines a basic WML document with a single card.

first.wml

<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
    "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="index" title="Welcome">
<p>
    This is my first WML document.
</p>
</card>
</wml>

Formatting Text

The following elements are supported in WML to format how the text will be displayed on the device.

Basic Elements to Format Text
Element Description
<b> some text </b> The text between these tags will be rendered in bold
<big> some text </big> The text between these tags will be rendered with a large font
<br/> This tag will force a new line. As the tag doesn't have a corresponding closing tag, a forward slash is required at the end
<em> some text </em> The text between these tags will be rendered with emphasised
<i> some text </i> The text between these tags will be rendered in italic
<p> some text </p> All text between these tags are treated as a paragraph
<small> some text </small> The text between these tags will be rendered with a small font
<strong> some text </strong> The text between these tags will be rendered with a strong emphasis
<u> some text </u> The text between these tags will be rendered underlined

The following example extends the original document to include some extra formatting.

formatted.wml

<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
    "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="index" title="Welcome">
<p align="center">
    This is my <br/><em>first</em><br/> WML document.
</p>
</card>
</wml>

Output From Program

The image shows the screen of a mobile phone with the output from the program.

Displaying Special Characters in WML

The following characters all have reserved meanings in WML. To show the characters on the device, you must use the code.

Special Characters
Character Description Code
< Less than &lt;
> Greater than &gt;
' Apostrophe &apos;
" Quote &quot;
$ Dollar sign $$
Non-breaking space &nbsp;

You might also like...

Comments

About the author

Gez Lemon United Kingdom

I'm available for contract work. Please visit Juicify for details.

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The trouble with programmers is that you can never tell what a programmer is doing until it's too late.” - Seymour Cray