Login for Software or Support

CoffeeCup - HTML Editor, Flash & Web Design Software

Over 48,871,587 Downloads in 87 Countries

Tell a Friend About Our Cool Software

Buy the Book Here !

Chapter 3: Preserving White Space


You learned in Chapter 2 how HTML normalized white space in your document. Any white space in your content--spaces, tabs, and new lines-
-is collapsed to a single space. This works well in most situations, but there are times when you have text that you want displayed exactly as-it, white space and all. An example might be a poem that has been carefully laid out with spaces and tabs to get the exact indentation that the author wants. In this situation use the <pre> tag, which stands for preformatted. White space is not normalized within <pre> tags--it is displayed exactly as entered. The <pre> tag also forces the browser to use a monospaced font, in which all characters are the same width.

The following HTML will demonstrate this. It contains two paragraphs that are identical except that the second one uses the <pre> tag to preserve white space. Figure 3-4 shows how this HTML is rendered.

<body>
<p>one
     two       three

four
five
</p>
<p><pre>one
     two       three

four
five
</pre></p>
</body>
Pre code

Figure 3-4. Use the <pre> tag to display content with white space preserved and in a monospaced font.


Table of Contents
Download Our Software:

... and don't forget about our Free Software

CoffeeCup Home Page | Software | Copyright & Legal | Site Map | © 1996 - 2008 CoffeeCup Software, Inc.