Home | HTML Tutorials | JavaScript Editor JavaScript EditorGet Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.

The Web Design Group



PRE - Preformatted Text

Syntax <PRE>...</PRE>
Attribute Specifications
Contents Inline elements except IMG, OBJECT, APPLET, BIG, SMALL, SUB, SUP, FONT, BASEFONT
Contained in APPLET, BLOCKQUOTE, BODY, BUTTON, CENTER, DD, DEL, DIV, FIELDSET, FORM, IFRAME, INS, LI, MAP, NOFRAMES, NOSCRIPT, OBJECT, TD, TH

The PRE element contains preformatted text. Visual browsers should render preformatted text in a fixed-pitch font, should not collapse whitespace, and should not wrap long lines.

PRE is useful for formatting computer code or poetry where whitespace is important, but since preformatted text is inherently visual, authors should avoid dependence on it wherever possible. When using PRE, authors should avoid altering the element's fixed-pitch font or non-collapsing whitespace properties by means of style sheets.

The following example features Java code in a PRE element:

<PRE><CODE CLASS=Java>
class HelloWorld {
  public static void main(String[] args) {
    System.out.println("Hello World!");
  }
}
</CODE></PRE>

The code in the preceding example would be more difficult to read if it were not preformatted, and so PRE is used to provide the proper spacing. Note that the CODE element is also included to add structural information.

The deprecated WIDTH attribute of PRE tells the browser the expected line length of the preformatted block so that a suitable font size or margin can be used. Browsers ignore this attribute in practice.

The bidirectional algorithm that determines the directionality of text still applies within the PRE element.

More Information

Home | HTML Tutorials | JavaScript Editor JavaScript EditorGet Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.