Preformatted Text

Level: 0

The preformatted text element <pre> presents sections in fixed-width font, and so is suitable for text which has been formatted for a teletype by some existing formatting system.

The <pre> element may be used with the optional width attribute, which is a Level 1 feature. The width attribute specifies the maximum number of characters for a line and allows the presentation system to select a suitable font and indentation. Where the width attribute is not present, it is recommended that a width of 80 be assumed. Where width is supported, it is recommended that at least widths of 40, 80 and 132 characters be presented optimally, with other widths being rounded up.

Within preformatted text:

References to the "beginning of a new line" do not imply that the renderer is forbidden from using a (constant) left indent for rendering preformatted text. The left indent may of course be constrained by the width required.

An example of using the <pre> element is:

<pre width="80">

This is an example line.

Within a preformatted element, the constraint that the rendering must be on a fixed horizontal character pitch may limit or prevent the ability of the renderer to render highlighting elements specially.

Preceding Section:
Following Section: Forms and Input fields
Parent Section: Body
Contents of HyperText Markup Language