English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag Reference

HTML: <pre> tag

The HTML <pre> tag defines preformatted text that preserves whitespace and line breaks in the HTML document. This tag is also commonly referred to as the <pre> element.

Online Example

Formatted Text:

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>Basic Tutorial(oldtoolbag.com)</title> 
</head>
<body>
<pre>Text goes here    preserving whitespace
and preserving line breaks</pre>
</body>
</html>
Test to see ‹/›

Browser compatibility

IEFirefoxOperaChromeSafari

Most browsers currently support the <pre> tag.

Tag definition and usage instructions

The <pre> tag can define preformatted text.

Spaces and line breaks within the <pre> tag will be preserved and displayed exactly the same as the spaces within the <pre> tag.

Text enclosed in <pre> tag elements usually preserves spaces and line breaks. The text will also be displayed in a monospaced font.

Hints and Notes

Hint: A common use of the <pre> tag is to represent the source code of a computer.

in HTML 4.01 with HTML5differences

in HTML 4.01 in, the "width" attribute is deprecated and cannot be used. HTML5 The "width" attribute is not supported.

Attribute

AttributeValueDescription
widthnumberHTML5 This attribute is not supported. HTML 4.01 This attribute is deprecated. Define the maximum number of characters per line (usually 40,80 or 132)

global attributes

<pre> tag supports global attributes, see the complete attribute table HTML Global Attributes.

event attributes

<pre> tag supports all HTML Event Attributes.