Name

pre

Synopsis

    <pre>...</pre>

Attributes

Core (id, class, style, title), Internationalization, Events

Deprecated Attributes

width="number"

Preformatted text is unique in that it displays exactly as it is typed in the HTML source code—including all line returns and multiple character spaces. Long lines of text stay intact and are not reflowed. The pre element in this example displays as shown in Figure 10-1. The second part of the figure shows the same content marked up as a p element for comparison.

<pre>    This is               an             example of

           text with a          lot of
                                curious
                                whitespace.</pre>

    <p>
    This is               an             example of

           text with a          lot of
                                curious
                                whitespace.</p>

Preformatted text is meant to be displayed in a fixed-width font to preserve the alignment of columns of characters. Authors are discouraged from changing the font face and whitespace settings with style sheets. Preformatted elements may include any inline element with the exception of img, object, big, small, sub, sup, and font, all of which would disrupt the column alignment of the fixed-width font.

Preformatted text compared to a paragraph

Figure 10-1. Preformatted text compared to a paragraph

Get Web Design in a Nutshell, 3rd Edition 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.