<PRE>NN all   IE all   HTML all
<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 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 spaces (&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
IE [window.]document.all.elementID
COLSNN 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 governs the line width.

 
Example
<PRE COLS=80>...</PRE>
 
Value
Any positive integer.
 
Default None.
WIDTHNN n/a   IE n/a   HTML 4
WIDTH="columnCount"Optional
 

The HTML 4.0 specification introduces the WIDTH attribute to allow setting 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.

 
Example
<PRE WIDTH=80>...</PRE>
 
Value
Any positive integer.
 
Default None.
WRAPNN all   IE n/a   HTML n/a
WRAPOptional
 

The presence of the WRAP attribute instructs Navigator to word-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
Hosted by uCoz