O'Reilly logo

Learning WML, and WMLScript by Martin Frost

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Attributes

Start-tags and empty-element tags (but not end-tags) may also have attributes . (In Example 1.2, the title on the <card> tag and the src on the <img> tag are both attributes.) Attributes affect the behavior of the whole element, which is why they can’t appear on end-tags (the only purpose of the end-tag is to mark the end of the element). The effects of attributes vary between different elements: the title attribute on the <card> element sets an optional title to be displayed with the card, while the src attribute on the <img> element gives the URL at which the image can be found. You can also add an align="center" attribute to the <p> element, which centers that paragraph of text (if the browser supports the feature).

A further slight difference between WML and HTML is in the quoting of attribute values. In HTML, attribute values may appear in single quotes (attr='value'), in double quotes (attr="value"), and most web browsers also allow them to be unquoted altogether (attr=value), although this isn’t strictly valid. WML doesn’t allow unquoted attribute values: all values must appear within either single or double quotes.[6]

Notation for Attributes

Within this book, whenever an attribute is described, a brief summary of the type of value it takes is given in parentheses after its name. The following terms are used in these descriptions:

string

The value can be any string.

url

The value should be a valid URL. Unless noted otherwise in the description of the attribute, relative URLs (where only part of the URL is given) are OK; these are resolved relative to the current document’s URL. Resolving is the process of taking an incomplete (relative) URL and turning it into a complete (absolute) URL. It is described in detail in Appendix A.

number

The value should be a nonnegative integer.

length

The value represents a length on the browser’s display. It can be specified either as a whole number of pixels or as a percentage (which represents a percentage of the width or height of the screen). In either case, the value must not be negative (but may be zero).

boolean

The value should be one of the strings true or false. Case is important!

name

The value should be a string containing only letters, digits, dots, colons, hyphens, and underscores. It is better, however, to avoid the dots, colons, and hyphens, and use only letters, digits, and underscores.

variable

The value may contain embedded variable references (see Chapter 2, for more information on variables).

optional

The attribute may be omitted.

required

The attribute must be present for the element to be processed correctly. Many browsers will refuse to process a deck if required attributes are missing.

default

The default value for the attribute. This value is used if the attribute isn’t specified on the tag. Only optional attributes can have defaults.



[6] The rules for quoting attribute values are another thing that will be familiar to XML users, since WML takes them from XML. If you don’t know XML, just remember you must use either single or double quotes around all attribute values.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required