Name

<PRE> — NN all IE all HTML all

Synopsis

<PRE>...</PRE>

End Tag: Required

The PRE element defines a block of preformatted text. Preformatted text is usually rendered by default in a monospace font and, more importantly, it preserves the whitespace (multiple spaces between words and new lines) entered into the source code for the content. Unlike the deprecated PLAINTEXT element, the PRE element doesn’t ignore HTML tags. Instead, it passes such tags onto the browser for normal rendering. If you want to display HTML tags in a block of preformatted text, use entities for the less-than (&lt;) and greater-than (&gt;) symbols. This prevents them from being interpreted as genuine tags but renders the symbols within the preformatted text block.

Browsers are supposed to ignore a whitespace line break immediately following a PRE element start tag in case you wish to start the content on a new line in the source code. By and large, the Version 4 browsers follow this rule (with the exception of IE 4 for the Mac).

The HTML 4.0 specification is adamant about the PRE element maintaining its monospaced font size and line spacing. It lists the following elements that should not be included inside a PRE element: APPLET, BASEFONT, BIG, FONT, IMG, OBJECT, SMALL, SUB, and SUP. Any one of these destroys the fixed-size pitch of the PRE element. The recommendation also encourages authors to avoid overriding the monospaced font settings with style sheets.

One last admonition concerns using tab characters ...

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.