<PRE> | NN all IE all HTML all
<PRE>...</PRE> | HTML 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 the HTML tags 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 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 to indent or align text within a pre element. Not all browsers render tab characters the same way. Avoid potential problems by using space characters and let the pre element's preservation of whitespace do the job. No nonbreaking space entities (&nbsp;) are necessary in a pre element.

Example
    <P>Here is the script example:</P>
    <PRE>
    &lt;script language="JavaScript"&gt;
       document.write("Hello, world.")
    &lt;/script&gt;
    </PRE>
Object Model Reference
    [window.]document.getElementById(elementID)
Element-Specific Attributes

cols | width | wrap

Element-Specific Event Handler Attributes
None.

cols | NN all IE n/a HTML n/a
cols="columnCount" | Optional
The maximum number of characters per line of preformatted code. This Navigator-specific attribute automatically sets the wrap attribute to true. Without this attribute, the source code formatting (or width attribute, where supported) governs the line width.
Example
    <PRE cols="80">...</PRE>
Value
Any positive integer.
Default
None.

lang | NN 3 IE 4 HTML 4
lang="languageCode" | Optional
The language being used for the element's attribute values and content. A browser can use this information to assist in proper rendering of content with respect to details such as treatment of ligatures (when supported by a particular font or required by a written language), quotation marks, and hyphenation. Other applications and search engines might use this information to aid the selection of spell-checking dictionaries and the creation of indices.
Example
    <SPAN lang="de">Deutsche Bundesbahn</SPAN>
Value
Case-insensitive language code.
Default
Browser default.
Object Model Reference
    [window.]document.getElementById(elementID).lang

width | NN n/a IE n/a HTML 4
width="columnCount" | Optional
The HTML 4 specification introduces the width attribute to allow you to set a maximum number of characters to be rendered on a preformatted line of text. Presumably, browsers that support this attribute in the future will wrap lines so that words do not break in the middle. Without this attribute, the source code formatting governs the line width. Navigator provides this functionality with the cols attribute. Note that the CSS width attribute does not affect this element in IE 5/Mac or IE 6/Windows. Even when it does, however, the units of measure do not include a character count.
Example
    <PRE width="80">...</PRE>
Value
Any positive integer.
Default
None.

wrap | NN all IE n/a HTML n/a
wrap | Optional
The presence of the wrap attribute instructs Navigator to wrap preformatted text so that text does not run beyond the right edge of the browser window or frame. wrap is set to true automatically when the cols attribute is set.
Example
    <PRE wrap>...</PRE>
Value
The presence of the attribute sets its value to true.
Default
false