Empty-Element Tags

Now, just to worry all the HTML users some more, check out Example 1.2.

Example 1-2. An Interesting Tag

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC
    "-//WAPFORUM//DTD WML 1.1//EN"
    "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>
    <card title="Another WML Example">
        <p><img src="img/pic.wbmp" alt="Image"/></p>
    </card>
</wml>

You should recognize most of the structure from Example 1.1, and the <img> tag may be familiar from HTML, but look more closely at the end of the tag: note the extra slash. This is required in WML whenever a tag has no matching end-tag. (An end-tag has a slash after the first angle bracket, like </end>.) These so-called empty-element tags are quite common in both WML and HTML, but HTML doesn’t decorate them in any special way, so they look just like start-tags. This makes some unnecessary work for the browser and any other program that has to read the file, so WML makes the structure more consistent.[4]



[4] Again, you may recognize this as another feature WML takes from XML. This feature is critical to XML, and it also makes WML files easier for the browser to read and parse. If you don’t know XML, don’t worry: just remember to add the extra slash whenever there isn’t a matching end-tag.

Get Learning WML, and WMLScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.