Home > Abakada: Back to Basics > Language References > HTML Elements > PRE Element
Renders text in a fixed-width font. | HTML 2, 3.2, 4, 4.01, 5 |
HTML Syntax
<pre
class = classname
id = value
style = css_style_rules
title = text
>
NOTE: Both start and end tags are required.
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.
The <pre>
element has no attribute of its own, but supports global attributes common to all HTML elements.
The following shows how the pre element may be used.
<p>The basic structure of an HTML document is: </p>
<pre>
<html>
<head> Header info goes here </head>
<body> Body content goes here </body>
</html>
</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>
CODE KBD SAMP TT XMP