Next / Previous / Contents / TCC Help System / NM Tech homepage

9.6. The pre element: Display verbatim text

The purpose of the pre element is to display a block of text exactly as it appears in the original XHTML; “pre” stands for “preformatted.”

The pre element works differently than a normal paragraph (the p element): in normal paragraphs, all whitespace (including spaces, tabs, and line breaks) is “normalized;” that is, leading and trailing spaces are ignored, and each clump of whitespace that occurs between two words is reduced to a single space. Then the resulting text is reformatted into lines that fit into the available space.

However, this kind of mashing-and-extruding process is unsuitable for the display of text such as computer programs, poetry, and such. To preserve all whitespace and line breaks in a group lines from your XHTML, enclose those lines in a pre element. Here is the content model:

element pre
{ Common.attrib,

In a pre element, you can use any of the common attributes described in Section 15.3, “The common attributes: Common.attrib.


You can use any mixture of text and inline elements as the content of a pre element; see Section 10, “Inline content: Inline.model.

Most browsers will not only preserve the spacing of the lines inside, but they will also render it in a monospaced font so that the letters line up in nice columns. In the example below, we definitely want the line numbers and statements to align vertically.

   20 GOTO 10
   30 END