asp.net.ph

Skip Navigation LinksHome > Abakada: Back to Basics > Language References > HTML Elements > PRE Element

<pre> Element


Renders text in a fixed-width font.HTML 2, 3.2, 4, 4.01, 5

HTML Syntax

NOTE: Both start and end tags are required.

Remarks

The <pre> element displays preformatted text in a fixed-width font. The element displays all white space and line breaks exactly as they appear, preserving its original layout.

pre is commonly used to show programming code blocks, tabulated information, and blocks of text that were created for some text-only form, such as electronic mail messages and news postings.

Unlike the <xmp> and <plaintext> elements, pre does not suppress interpretation of other HTML tags.

As such, special symbols must be used for any character that has a meaning in HTML that authors wish to be displayed, rather than interpreted. For example, the less than < and greater than > symbols to denote markup tags.

For more information on special symbols, see HTML Character Entity Reference.

Some cases where the pre element could be used:

  • Including fragments of computer code, with structure indicated according to the conventions of the code language.
  • Including an email, with paragraphs indicated by blank lines, lists indicated by lines prefixed with a bullet, and so on.

This element is a block element. All pre elements start on a new line.

Attributes

The <pre> element has no attribute of its own, but supports global attributes common to all HTML elements.

Example

The following shows how the pre element may be used.

<p>The basic structure of an HTML document is: </p>
<pre>
   &lt;html&gt;
      &lt;head&gt; Header info goes here &lt;/head&gt;
      &lt;body&gt; Body content goes here &lt;/body&gt;
   &lt;/html&gt;
</pre>

which would render on a Web page as

The basic structure of an HTML document is:

<html>
   <head> Header info goes here </head>
   <body> Body content goes here </body>
</html>

External References

See Also

CODE   KBD   SAMP   TT   XMP



Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note