Example

A simple <pre> tag:

Laboratory

description & Usage

The <pre> tag is used to display preformatted text.

In simpler terms, if you want to write some text in HTML and have it displayed in the browser exactly as written, we use the <pre> tag.

For example, if you want to place multiple spaces between two words in a text or force a line break at a certain point.

Browsers use a monospace font for the content inside this tag.

Related tags to <pre> are:

description tag

Display computer code

font-family: monospace

<code>

 

Display computer code output

font-family: monospace

<samp>

 

Show keyboard buttons

font-family: monospace

<kbd>

 

Display variable and mathematical expression

font-style: italic

<var>

 

Pre-formatted text

font-family: monospace

There are other default styles

<pre>

 

 

Browser compatibility and Support

# Chrome Edge Firefox Safari Opera
<pre>

Global Attributes

The <pre> tag supports the HTML Global Attributes.

Event Attributes

The <pre> tag supports the HTML Event Attributes.

Default CSS

Most browsers will display the <pre> tag with the following default style: