The <br> Element

The <br> element is one of the simplest in WML. It takes no attributes and is always specified as an empty-element tag, <br/>. It marks a line break in a paragraph of text: when the browser encounters a <br/>, it starts a new line.

You may ask what the difference is between using a <br/> to break lines:

<p>text<br/>more text</p>

and using another paragraph:

<p>text</p><p>more text</p>

The answer is that WAP doesn’t specify the difference. Some browsers insert a small amount of blank space between paragraphs, but won’t do this at a <br/>, but not all browsers actually make a distinction at all. Note that if you need to change the alignment or wrapping mode of the text, you have to use a <p>, since the <br/> tag can’t specify these attributes.

A good rule of thumb is to use <p> where the text naturally breaks into blocks, just like the paragraphs in normal text. Use <br/> where you want a break for presentation, but the text continues with part of the same block afterward. For example, when putting normal paragraphs of text into a deck, use one <p> element for each paragraph:

<p>
    A good rule of thumb is to use &lt;p&gt; where the
    text naturally breaks into blocks, just like the
    paragraphs in normal text. Use &lt;br/&gt; where
    you want a break for presentation, but the text
    continues with part of the same block afterward.
</p>
<p>
    For example, when putting normal paragraphs of
    text into a deck, use one &lt;p&gt; element for
    each paragraph:
</p>

When entering something like ...

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.