Create a website RSS feed

Preformatted Text

Preformatted Text

Last update on: 05-17-2008
The one exception to this rule is the preformatted text tag pre. Any white space that you put into text surrounded by the pre and /pre tags is retained in the final output. With these tags, the spacing in the text in the HTML source is preserved when it's displayed on the page.

The catch is that preformatted text usually is displayed (in graphical displays, at least) in a monospaced font such as Courier. Preformatted text is excellent for displaying code examples in which you want the text formatted with exactly the indentation the author used. Because you can use the <pre> tag to align text by padding it with spaces, you can use it for simple tables. However, the fact that the tables are presented in a monospaced font might make them less than ideal.


When you're creating text for the <pre> tag, you can use link tags and character styles, but not element tags such as headings or paragraphs. You should break your lines with hard returns and try to keep your lines to 60 characters or fewer. Some browsers might have limited horizontal space in which to display text. Because browsers usually won't reformat preformatted text to fit that space, you should make sure that you keep your text within the boundaries to prevent your readers from having to scroll from side to side.
Be careful with tabs in preformatted text. The actual number of characters for each tab stop varies from browser to browser. One browser might have tab stops at every fourth character, whereas another may have them at every eighth character. You should convert any tabs in your preformatted text to spaces so that your formatting isn't messed up if it's viewed with different tab settings than in the program you used to enter the text.

Formatting Text's lessons:

Character-Level Elements
Formatting Using CSS
Preformatted Text
Horizontal Rules
Line Break
Addresses
Quotations
Text Alignment
Fonts And Its Attributes
Special Characters

Banner HomeServices Contact |  ©2009 http://www.iteachweb.net/