Writing HTML |
About |
Index |
previous |
next |
Preformatted Text
How do you
display text
where space and return
characters count?
Objectives
After this lesson you will be able to:
- Create a table of aligned text
- Control the placement of text on a page when tabs and spaces
are important.
Lesson
Note: If you do not have the working documents from the previous
lessons, download a copy now.
In previous lessons we have seen that a WWW browser will ignore extraneous space
characters and carriage returns. However, there are some instances where it
will be important to control these aspects of the page layout. In this lesson,
the example will be where we want to insert a table of text with aligned
columns.
The preformat tag instructs your WWW broder to display the text exactly as
written in the HTML document, including spaces, and carriage returns.
A browser typically displays such text as a monospaced type. An example
of the preformat
tag:
<pre>
We have indented with 5 space characters.
And used the carriage return to jump
to
a
new
line.
Here we
use
spaces to
create a
text table.
</pre>
Without the <pre> and </pre> tags,
the same HTML produce:
We have indented with 5 space characters.
And used the carriage return to jump
to
a
new
line.
Here we
use
spaces to
create a
text table.
With the preformat tag, it helps if the text editor you are using can
display in a mono-spaced font (such as "courier" or "monoco"); if not you will
have to count spaces when aligning text into columns.
For our Volcano lesson, we want to add a table under the Introduction section
that lists several well-known volcanoes, when they erupted, and the volume
of erupted material. To do this:
- Open the second HTML file, Volc.html in your text editor.
- Under the last portion of the "Introduction" section, place a header of level 4
(<h4>) with the text "Volumes of Some Well-Known Volcanic Eruptions" (If you
do not remember how to make headers, see lesson 3).
- Below this heading, enter the following text:
<pre>
Eruption Date Volume in km^3
-------- ---- --------------
Paricutin, Mexico 1943 1.3
Mt. Vesuvius, Italy 79 A.D. 3
Mount St. Helen, Washington 1980 4
Krakatoa, Indonesia 1883 18
Long Valley, California pre-historic 500 - 600
Yellowstone, Wyoming pre-historic 2400
</pre>
NOTE: In this example we use space characters to make the first column left
justified and the other 2 columns center-justified. The dashes are used
to highlight the column headings.
- Save and Reload the HTML file.
Check Your Work
Compare your WWW document with a sample
of how this document should appear. If your
WWW document was different than the sample, review the text you
entered in the text editor. If the columns are not aligned, then
it is likely that you are missing or have added space characters.
Review
Review topics for this lesson:
- How does the preformt tag change the way that the World Wide Web
interprets HTML?
- What other situations might you use this tag?
More Information
Throughout this lesson, we have used the preformat tag
to display the text you should enter into your HTML documents.
Independent Practice
Add a table or chart to your HTML document using the preformat tag.
Coming Next....
Use special character sets to add some âccèñt
to your WWW pages.
| Lesson Index |
previous lesson "HyperGraphics" |
next lesson "Special Characters" |
Writing HTML Lesson 9: Preformatted Text
©1995
Maricopa Center for Learning & Instruction (MCLI)
Maricopa County Community College District, Arizona
The Internet Connection at MCLI is
Alan Levine--}
Comments to levine@maricopa.edu