HTML <pre> tag

When 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 its spaces and line breaks 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, and related attributes and browser compatibility.
The <pre> tag is quite useful for displaying organized computer code.
Example of <pre> 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
Edge | Internet Explorer | Firefox | Safari | Opera | Chrome |
---|---|---|---|---|---|
All versions | All versions | All versions | All versions | All versions | All versions |
Browser, Compatibility, Container tag, Paragraph, Web design terms