Basic HTML Tutorial: Preformatted
Text
Home > Build
> Programming > HTML
> Basic
HTML Tutorial
1.17 Preformatted Text
We mentioned recently that browser's ignored
extra spaces and all carriages. That isn't entirely true.
There is a way to use Preformatted text, where the browser
will interpret the text as you format it in the text editor.
This would be a nice way to format text, but the one problem
is that all preformatted text is displayed in a monospace
font, such as Courier. Monospace fonts are not very attractive,
and it would be considered bad design in many cases.
There are some situations where preformatted
text could come in handy. For example, a company chart. Or
data that doesn't necessarily need to be dressed up.
Preformatted text is also a good way to import
text from another document such as Microsoft Word. If a Word
document is pasted into a text editor, everything will display
as one block. If the word document is pasted within the <PRE>
container, most of the formatting will stay intact.
Preformatted text is turned on with the <PRE>
tag and turned off with the </PRE>. Everything in between
is displayed as formatted in the editor.
Here is an example:
<HTML>
<HEAD>
<TITLE>Preformatted text</TITLE>
</HEAD>
<BODY>
<PRE>
# of Pork and Beans in stock
----------------------------
Pork Beans Total
5/1 1 2 3
5/2 2 5 7
</PRE>
</BODY>
</HTML>
See
it in the Browser:
1.18 Special Characters