HTML Basics
Stanford University Libraries & Academic Information Resources

Preformatted text

 [Previous Page]  [Tutorial Top]  [Tech Guide]  [Next Page]

For most text, we let the browsing software determine how best to format our text for presentation to the reader. As part of this formatting the browser will, for most types of text, collapse whitespace, including newlines, flowing text together into a form that best suits the reader's display. In some situations, however, the newlines, spacing, etc., are an integral part of the meaning of the text, and must be controlled by the author. For this situation, HTML offers <pre>, which is used to identify pieces of preformatted text intended to be displayed in a monospace font with all the whitespace intact. In other words, we use <pre> to tell the browser "don't do any formatting to this section; just display it as is, in a monospaced font".

One common use for the pre element is to allow the inclusion of verse, as in this, from Christne la Belle's The Possibility of an Early Fall

Example

<pre>
    Even as you say it:
                        "there has to be
    a first time"
                  I try not to see
    the difference
                   between us
    or the fall of dust
                        from a book
    dated 1883
               that for a moment
    is caught
              by the sun
    moves on
             almost as though it were
    capable
            of naming its own
    direction.
    ...
</pre>

Another important use for pre is the markup of formulae. Fortunately, entity references are expanded inside pre, as in the superscript 1 (¹) below. Because the entity &#185; takes up 6 'spaces' where the replacement character ¹ takes only one, it can be tricky to get things to line up properly and usually takes some trial and error.

Example

<p>Alkoxysilanes are a family of monomeric molecules which react with water
to form either silica or an alkylpolysiloxane.  Three alkoxysilanes are
commonly used to consolidate stone.  They are tetraethoxysilane,
triethoxymethylsilane and trimethoxymethylsilane [109].
Tetraethoxysilane is an example of a silicic acid ester [110].  Their
polymerization is initiated by a hydrolysis reaction,</p>

<pre>

     |         catalyst     |                               (2)
  --Si-OR + H20           --Si - OH + ROH.
     |                      |


  Then polymerization commences,

     |          |                         |    |
   --Si -- OH + Si-OR                   --Si-O-Si-+ R&#185; OH-    (3)
                                          |    |

  where R = CH3 (methyl), C2H5 (ethyl)
  and  R&#185; = H, CH3, C2H5
</pre>

<p>Polymerization continues until all the alkoxy groups have been liberated
and either an alkylpolysiloxane or silica is produced.  Silica is
produced by the polymerization of a silicic acid ester.  An
alkylpolysiloxane is formed by the polymerization of other types of
alkoxysilanes.  An acidic catalyst, e.g., hydrochloric acid, is used to
increase the rate of hydrolysis (equation 2).  The alkoxysilanes are
diluted with solvents to reduce their viscosities.  Thus, their reaction
rate and depth of penetration into stone can be controlled.  It is
claimed that their consolidating ability can be increased by using a
mixture of alkoxysilanes [110].</p>

which is rendered

Alkoxysilanes are a family of monomeric molecules which react with water to form either silica or an alkylpolysiloxane. Three alkoxysilanes are commonly used to consolidate stone. They are tetraethoxysilane, triethoxymethylsilane and trimethoxymethylsilane [109]. Tetraethoxysilane is an example of a silicic acid ester [110]. Their polymerization is initiated by a hydrolysis reaction,


     |         catalyst     |                               (2)
  --Si-OR + H20           --Si - OH + ROH.
     |                      |


  Then polymerization commences,

     |          |                         |    |
   --Si -- OH + Si-OR                   --Si-O-Si-+ R¹ OH-    (3)
                                          |    |

  where R = CH3 (methyl), C2H5 (ethyl)
  and  R¹ = H, CH3, C2H5

Polymerization continues until all the alkoxy groups have been liberated and either an alkylpolysiloxane or silica is produced. Silica is produced by the polymerization of a silicic acid ester. An alkylpolysiloxane is formed by the polymerization of other types of alkoxysilanes. An acidic catalyst, e.g., hydrochloric acid, is used to increase the rate of hydrolysis (equation 2). The alkoxysilanes are diluted with solvents to reduce their viscosities. Thus, their reaction rate and depth of penetration into stone can be controlled. It is claimed that their consolidating ability can be increased by using a mixture of alkoxysilanes [110].


A more prosaic use of <pre> is to format columnar material such as tables, a use which will become unnecessary soon, as the next version of HTML is expected to include facilities for marking up tabular material.

 [Previous Page]  [Tutorial Top]  [Tech Guide]  [Next Page]


Walter Henry
Stanford University Libraries and Academic Information Resources