8. WML Preformatted Text: <pre>

The <pre> tag is used to specify preformatted text in WML. Preformatted text is text of which the format follows the way it is typed in the WML document.

In WML, leading and trailing whitespaces (i.e. spaces, tabs and newlines) of a paragraph are not displayed. Furthermore, two or more whitespaces in a paragraph are shown as one whitespace on the screen of mobile devices. Such behavior is demonstrated in the following WML example.


(preformatEg1.wml)

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

<wml>
  <card id="card1" title="WML Tutorial">
    <p> Hello, welcome
to
our
          WML tutorial .</p>
  </card>
</wml>



Sony Ericsson T610


Sony Ericsson T68i


Nokia Mobile Browser 4.0


To preserve the formatting of the text, you have to use the <pre> element. WAP browsers treat the content enclosed in the <pre></pre> tag pair as preformatted and whitespaces are left intact.

The following WML example illustrates how to use the <pre> element:


(preformatEg2.wml)

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

<wml>
  <card id="card1" title="WML Tutorial">
    <pre> Hello, welcome
to
our
          WML tutorial .</pre>
  </card>
</wml>


The result of the above WML example in WAP browsers is shown below (the screenshot for Sony Ericsson T68i is not shown since the <pre> element does not work in the emulator):



Sony Ericsson T610





Nokia Mobile Browser 4.0


Previous Page Page 11 of 50 Next Page


Feedback Form (ExpandCollapse)

What do you think about this web page?






(Optional) Please provide us more details. For example, suppose you select option 2 above, can you tell us specifically what information is missing? You can also suggest anything that can help us improve this web page.

(Optional) Your name:

(Optional) Your email address:

Please enter again to confirm:

Due to the amount of messages we received, we may not be able to reply to all messages.

A button for going back to the top of this page