WML (Wireless Markup Language) : An Introduction

Share this article

WML (Wireless Markup Language) is the new web language for making sites on mobile phones. Over the past few months new WAP (Wireless Applications Protocol) phones have become extremely popular and many large websites have created special ‘mobile’ versions of their site. Many people predict that, over the next few years, WAP sites will become extremely popular and e-commerce over mobile phones will be widly available.
Why Should I Use WML?
Although you might not have any plans immediately for creating a WAP version of your site, it is always a good idea to get involved in new technology. All you need to do is make a small site (even one page) which tells people a bit about your website. In the future you can develop the site further with things like e-mail and information for people to access directly from their phones. The main sites which will benefit from WAP are ones providing a service like e-mail, live sports scores or a calendar service etc. but there are many other uses. For example, a site giving music reviews could put their reviews on a WAP site. People could then read the reviews on their mobile phone while browsing through the CDs in a shop.
I Don’t Have A WAP Phone!
To create a WAP site you don’t need a WAP enabled phone. You can get a WAP simulator for a PC. This is a piece of software which will give you a WAP phone on your desktop. You can then type in the URLs of WAP sites and then view them on your PC. You can get a very good free WAP simulator from YourWAP.com
How Do WAP Sites Compare To Normal Ones?
WAP sites are not like standard web sites at all. As an example, you are looking at part of the Gowansnet web site. wap_gnet As you can see, sites written in WML are monochrome, very limited and there is very little screen space. Because of this you must be very careful when you are designing a WAP site as it is nothing like a web site.
What Now?
Just read on to learn how to create a WAP site using WML. It is a great advantage if you know HTML as WML is a lot like it (in fact WML is just a variant of XML, another web language).
Create your first WAP site!
Let’s get straight into how to create a site. Note, a working knowledge of HTML is useful and you should really have either a WAP phone or a WAP simulator to view your site.
Finding A WML Host
Unfortunately WML cannot be run on all web hosts. For WML content to be run, a web host must make some changes to the configuration of their web server.
Declaring A WML Document
When you are creating a WML document all you need is notepad, just like for HTML. The first thing you should enter is: <?xml version=”1.0″?><!DOCTYPE wml PUBLIC “-//WAPFORUM//DTD WML 1.1//EN” “http://www.wapforum.org/DTD/wml_1.1.xml”><wml> this tells the phone that it is interpreting a WML document and which WML standards it is using.
Cards
Instead of having pages, WAP sites have cards. These are what is displayed on the screen at any one time, just like a page. More than one card can be inserted in each WML document. To declare a card, insert the following: <card id=”index” title=”My WAP Site” newcontext=”true”> This will make a card with the ID index (used for linking) and will display the text:
My WAP Site
at the top of the screen.
Closing Tags
Unlike with HTML, it is extremely important to close WML tags. If you do not, a page will certainly not work. You must close both the <card> and <wml> tags: </card> </wml> Now I am going to show you how to insert text and how to format it.
The <p> Tag
Just like in HTML the <p> tag is used to show where a paragraph begins and ends. Unlike HTML though, all text on a WML page must be inside these tags. You are not allowed to nest these tags either. One important thing to remember about WML is that, unlike HTML where a page will still display even if there is bad code, a WAP phone will just reject a page if there is code it doesn’t understand. As with HTML you use the tags as follows: <p> information </p>
Aligning Text
Aligning text in WML is nearly exactly the same as in HTML, except you can’t use the center tag. All aligning must be done using the following <p> tags: Center: <p align="center"> Right: <p align="right">
The <br/> Tag
In WML (as mentioned earlier) all tags must be closed. This causes problems when using old HTML tags (like <br>) which have no closing tag. To get around this, some tags have had a / put on the end e.g.
<br/>
This, like in HTML will make a line break.
Text
In WML there is actually no font tag (as you can only display text in the phone’s default font in black). To show text all you need to do is put it in between the <p> and </p> tags. Here is an example of a full WML document: <?xml version=”1.0″?><!DOCTYPE wml PUBLIC “-//WAPFORUM//DTD WML 1.1//EN” “http://www.wapforum.org/DTD/wml_1.1.xml”> <wml> <card id=”index” title=”My WAP Site” newcontext=”true”> <p align=”center”> Welcome to my new WAP site. You can view this on your mobile phone anywhere in the world!<br/> It is amazing! </p> </card> </wml>
Hyperlinks + Images
Now I will show you how you can make this better by adding extra parts, linking to them (and other sites) and how to add images to your site.
More Cards
WAP sites have cards instead of pages. They are really the same as pages except that they can all be written in one file. To add another card, all you need to do is put in another <card> tag with a different ID to the others. For example: <card title=”About Me” id=”about”> information </card>
would be added below the first card but before the </wml> tag.
Linking
There are three ways to link to another WAP site, file or card. Just like in HTML these can either be the full path to a file or a relative link. To link to a WAP site you use the following:
<a href="http://gowansnet.waphosts.net/">Gowansnet</a>
in your text. To link to another file on your site you would use:
<a href="links.wml">My Links</a>
and to link to another card in the same page you use:
<a href="#about">About Me</a>
Images
Unfortunately, because WAP phones only have monochrome screens, images do not work very well on WML pages. They also use their own image format: WBMP. When you are creating an image to use on your site you will need to make it small (mobile phone screens are about 100×50 pixels). The easiest way to get an image into the WBMP format is to create it as a GIF or JPG (it can be in colour if you want) and then visit this site to convert it into a monochrome (black and white) WBMP image which you can then include on your site. Images in WML are inserted using the <img> tag, just like in HTML: <img src=”logo.wbmp” alt=”Logo” /> Again, you can see that a / has been added at the end as the <img> tag has no closing tag. It is very important that you also include the alt text as it will be displayed while the image is being downloaded.
Example Site
Below is the sample WML code for a small WAP site. It has two cards, an image, and a link to an external site: <?xml version=”1.0″?><!DOCTYPE wml PUBLIC “-//WAPFORUM//DTD WML 1.1//EN” “http://www.wapforum.org/DTD/wml_1.1.xml”> <wml> <card id=”index” title=”My WAP Site” newcontext=”true”> <p align=”center”> Welcome to my new WAP site. You can view this on your mobile phone anywhere in the world!<br/> <img src=”logo.wbmp” src=”Logo” /> </p> <p> Here are some links:<br/> <a href=”#about”>About Me</a><br/> <a href=”http://gowansnet.waphosts.net/”>Gowansnet</a> </p> </card> <card id=”about” title=”About Me”> <p>Here is some informatio about me. You can’t write too much in here, though as there is not much space<br/> You can scroll down the screen, of course. </p> <p align=”center”> <a href=”#index”>Back</a> </p> </card> </wml>
What Next?
If you would like to learn more about WML and the WAP standards you can visit the WAP Forum at www.wapforum.com

Frequently Asked Questions (FAQs) about Markup Language

What is the difference between HTML and WML?

HTML (HyperText Markup Language) and WML (Wireless Markup Language) are both markup languages used to create web pages. However, they are designed for different types of devices. HTML is used for desktop and laptop computers, while WML is designed for mobile devices like smartphones and tablets. WML is a compact language that can be used even on devices with limited processing capabilities and small screens. It also supports features like access to device hardware, which HTML does not.

How does WML work with WAP?

WML is a key component of the Wireless Application Protocol (WAP) which is a set of communication protocols for wireless devices. WAP allows devices to access internet services, such as web browsing, email, and online gaming. WML provides the interface that users interact with when using these services. It is designed to work well on small screens and with limited processing power, making it ideal for mobile devices.

What are the main features of WML?

WML is designed to be a simple, yet powerful language for creating mobile web pages. It supports features like text formatting, images, links, forms, and even access to device hardware. It also includes a scripting language, WMLScript, which allows for more complex functionality like calculations and decision-making.

How does WML compare to other mobile web technologies?

WML was one of the first languages designed specifically for mobile devices, and it set the standard for many of the features we now take for granted in mobile web design. However, as technology has advanced, other languages like HTML5 have become more popular. HTML5 is more powerful and flexible than WML, and it is supported by all modern web browsers. However, WML is still used in some legacy systems and in areas with limited internet connectivity.

Can I use WML on my website?

Yes, you can use WML on your website, but it may not be the best choice for most modern web projects. WML is not supported by all web browsers, and it lacks some of the features of more modern languages like HTML5. However, if you are creating a website for a specific purpose, such as a mobile app for a device with limited capabilities, WML may be a good choice.

What is the future of WML?

The future of WML is uncertain. While it was once the standard for mobile web design, it has been largely replaced by more powerful and flexible languages like HTML5. However, WML is still used in some legacy systems and in areas with limited internet connectivity. It is possible that WML will continue to be used in these areas for some time.

How can I learn WML?

There are many resources available online for learning WML. Websites like GeeksforGeeks and TutorialsPoint offer tutorials and examples that can help you get started. You can also find books and online courses that cover WML in more depth.

What are the benefits of using WML?

WML has several benefits, especially for mobile web design. It is a simple, compact language that can be used on devices with limited processing power and small screens. It also supports features like access to device hardware, which can be useful for certain types of apps.

What are the drawbacks of using WML?

The main drawback of WML is that it is not as powerful or flexible as more modern languages like HTML5. It is also not supported by all web browsers, which can limit the audience for your website or app.

Is WML still relevant today?

While WML has been largely replaced by more modern languages, it is still used in some legacy systems and in areas with limited internet connectivity. If you are working with these types of systems, or if you are creating a website or app for a device with limited capabilities, WML may still be relevant.

David GowansDavid Gowans
View Author

David has been developing Websites and helping Webmasters since 1999. He is the Webmaster of Free Webmaster Help, which provides Web building tutorials and articles, and has developed Free-Webhosting.info, a free Webhosting directory. He also offers scripting and design services to clients worldwide.

Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week