HTML <pre> Tag

Description

The <pre> HTML element defines a block of pre-formatted text. Such text is usually displayed in a monospaced font (fixed width). By default, any number of spaces in the code in a row on a web page is shown as one. The <pre> element allows you to bypass this feature and display the text as required by the developer.

Properties

Permitted Parents
Any element that accepts flow content
Content
Most inline tags and text
Start/End Tags
Start tag: required, End tag: required

Example

<pre>
Text in a pre element
is displayed in a fixed-width
font, and it preserves
both spaces and
line breaks
</pre>

Attributes

Attribute Definition
width Specifies the desired width of the preformatted text.

Global Attributes

The <pre> tag also supports the Global Attributes in HTML5

Event Attributes

The <pre> tag also supports the Event Attributes in HTML5

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
YesYesYes1YesYes
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
YesYes4YesYesYes

Last updated by CSSPortal on: 6th December 2019