HTML <pre>Tag


Examples

Preformatted text:

<pre>
This example demonstrates how to use the pre tag
blank lines and spaces
are controlled
</pre>

Try it yourself »

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

Most browsers currently support the <pre> tag.


Tag Definition and Usage Instructions

The <pre> tag defines preformatted text.

Text enclosed in a <pre> tag element usually preserves spaces and line breaks. The text is also rendered in a monospace font.


Tips and Notes

Tip:A common application of the <pre> tag is to represent computer source code.


Differences Between HTML 4.01 and HTML5

In HTML 4.01, the "width" attribute is deprecated and cannot be used. HTML5 does not support the "width" attribute.


Attributes

Attribute Value Description
width number HTML5 does not support this attribute. HTML 4.01 has deprecated this attribute.Defines the maximum number of characters per line (usually 40, 80, or 132).


Global Attributes

The <pre> tag supports global attributes. View the complete attribute table.HTML Global Attributes。


Event Attributes

The <pre> tag supports allHTML Event Attributes。

Other Extensions