Home HTML Space PRE Tag In HTML
Search MS Office A-Z   |   Search Web Pages/ Design A-Z

PRE Tag In HTML

The PRE tag is a great way to display preformatted text that needs specific spaces between lines, words, or even individual letters. That is, it's great if you don't mind giving up some control over page display.

Depending on your page layout and which browsers your visitors use, the loss of control may be considerable. That's because browsers have set ways (defaults) to display text inside a PRE tag.

For instance:

  • Fixed pitch fonts: Text inside a PRE tag always displays in the browser's default monopitch font, which is usually Courier. The rest of your page text may be in Arial or any other font you choose, but anything enclosed inside a PRE tag looks like somebody took a typewriter to it!

  • Default spacing: The PRE tag is a block-level element, so browsers place the same amount of space around them as around paragraph tags. Your preformatted text may end up farther away from the surrounding text than you wanted.

  • Horizontal scrollbars: If your preformatted text contains one or more long lines, the browser window stretches to accommodate them instead of wrapping the text. That may lead to unsightly horizontal scrollbars.

You can force the text to wrap using the WIDTH attribute. But this is where browser problems first appear. Explorer and even Opera ignore the WIDTH attribute, but Netscape 6 and 7 support it.

Here is         some text
              that  is
inside a PRE tag.