HTML <pre> tag

Updated: 10/11/2017 by Computer Hope

HTML pre tagWhen writing in HTML, the <pre> tag is a block element used to designate preformatted text. It is useful because the text between <pre> tags has both its spaces and line break preserved in addition to being displayed in a fixed-width font. The following sections contain information about this tag, including an example of it in use, as well as related attributes and browser compatibility.

Tip: The <pre> tag is quite useful for displaying organized computer code.

Example code

<pre>This is a sentence with some     preformatted text.</pre>

Example result

This is a sentence with some     preformatted text.

Deprecated attributes

Within an HTML tag, an attribute dictates certain aspects of an HTML element. Attributes are made up of a name and value pair; all tags support standard attributes. The only attribute unique to the <pre> tag is deprecated, meaning that it may function currently, but is not supported in going forward. In this case, CSS should be used in place of these attributes.

Attribute Description
width Designates the maximum number of characters per line

Compatibility

Internet Explorer Firefox Safari Opera Chrome
All versions All versions All versions All versions All versions

Browser, Compatibility, Paragraph, Web design terms