HTML <pre> tag

The <pre> tag is used to display preformatted text. A web browser will ignore spaces and line breaks, but with the <pre> tag they are preserved.

Attributes

Attribute Description Possible values
width Deprecated. The maximum allowed number of characters per line numCharacters

Standard attributes

class, dir, id, lang, style, title, xml:lang

For more information on standard attributes, check out our HTML standard attributes reference page.

Event attributes

onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup

For more information on event attributes, check out our HTML event attributes reference page.

Example

<p> The extra white spaces and line breaks in this paragraph will not be preserved </p> <br /> <pre> ..But it's alright because the pre tag is there when we need it with its incredible preformatting abilities! </pre>
Output:

The extra white spaces and line breaks in this paragraph will not be preserved


..But it's alright              because the pre tag  is              there 

when 

we          need       it

with its incredible

preformatting              abilities!

Tips & notes

The <pre> tag works to preformat not just text but any other content as well!

You can use the CSS white-space property which achieves the same effect as the <pre> tag. Learn how to use the white-space property in our CSS text properties tutorial.

Web Reference
  1. CSS reference
  2. RSS reference
  3. HTML reference


© Copyright 2011-2012 Landofcode.com
Terms of use | Privacy policy | Copyright information | Make a donation