Comments

Sometimes you may find that you want to leave a remark in your WML file to remind you how it works at some later date, or you may want to temporarily remove part of a file while you are testing something else. Comments are the answer.

A comment starts with the four characters <!-- and ends with the three characters --> . Everything that appears between these two markers, including tags, body text, entities, and line breaks, is ignored. Here are some examples:

<!-- A simple comment. -->

<!--This is
a comment that
spans several lines.-->

You can’t nest comments. The following doesn’t work:

<!-- A simple <!-- EMBEDDED COMMENT, NOT! -->   comment. -->

Moreover, the two characters -- can’t appear within the body of a comment, only at the end, as part of the --> terminator.

If for some reason you want the sequence <!-- in your body text, write it with an entity (which you would have to do for the < anyway):

&lt;!--

You may be worrying about using comments. Surely they end up sending lots of extra data to the browser, and you keep being told how saving bandwidth is really important? Don’t worry: the WAP gateway removes all comments as part of its processing, so the browser doesn’t even know they exist.

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.