You learned in Fundamental Concepts of HTML that 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 is, with white space and
all. 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 uses the <pre> tag to preserve white space.
Next Figure shows how this HTML is
shown in output.
<body>
<p>one
two three
four
five
</p>
<p><pre>one
two three
four
five
</pre></p>
</body>
Output:
one
two three
four
five
one
two three
four
five
0 comments:
Post a Comment