HTML <pre> tag

Updated: 09/12/2023 by Computer Hope
HTML pre tag

When writing in HTML (hypertext markup language), 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 and is 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.

Tip

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

All HTML tags support standard attributes that define the settings of an HTML element. In addition to the standard settings, the <pre> tag had the following unique attributes that are now deprecated.

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