HTML-Pre formatted Text
Using Preformatted Text
Is it absolutely necessary to use paragraph and line break elements for formatting text? Well, not really; HTML provides a container that can hold preformatted text. This is text that gives you, the author, much more control over how the viewer displays your document. The trade-off for this control is a loss of flexibility.The most common and useful preformatting tag is the
container. Text in acontainer is basically free-form with line feeds causing the line to break at the beginning of the next clear line. Line break tags and paragraph tags are also supported. This versatility enables you to create such items as tables and precise columns of text. Another common use of theelement is to display large blocks of computer code (C, C++, and so on) that would otherwise be difficult to read if the browser reformatted it.
Text in a
container can use any of the physical or logical text formatting elements. You can use this feature to create tables that have bold headers or italicized values. However, the use of paragraph-formatting elements such as or any of the heading elements is not permitted. Anchor elements can be included within acontainer.
The biggest drawback to the
container is that any text within it is displayed in a monospaced font in the reader's viewer. This tends to make long stretches of preformatted text look clunky and out of place.