The Web Design Group

PRE - Preformatted text


This element is also available in our updated HTML 4 reference. Some characteristics may have changed.

Appearance: <PRE> </PRE>
Attributes: WIDTH=n
Contents: TT, I, B, U, STRIKE, , EM, STRONG, DFN, CODE, SAMP, KBD, VAR, CITE, A, APPLET, BASEFONT, BR, MAP, INPUT, SELECT, TEXTAREA and plain text.
May occur in: BODY, DIV, CENTER, BLOCKQUOTE, FORM, TH, TD and DD, LI.

PRE is used to include sections of text in which formatting is critical. Unlike in the other HTML containers, text in a PRE pair will only be wrapped at the linebreaks in the source, and spaces will not be collapsed. You can even use tabs, although it is better to use multiple spaces since those will always be the right number.

Text inside this tag will be displayed in a monospaced font to retain the formatting. This is the reason you cannot include font-changing tags inside PRE text. Images are excluded because they can introduce problems with alignment. An image can't be translated to a certain number of characters.

The optional WIDTH attribute can be used to indicate how wide the text is (for example, WIDTH=80 for a typical text file). This would allow the browser to pick a font which fits the entire text in the current window. Unfortunately this isn't very widely supported.

Notes:

HTML 3.2 Reference  ~ Elements by Function  ~ Elements Alphabetically


Home, Forums, Reference, Tools, FAQs, Articles, Design, Links

Copyright © 1996 - 2006. Web Design Group All rights reserved.