HTML Tags

HTML <pre> Tag

Topic: HTML5 Tags ReferencePrev|Next

Description

The <pre> tag defines a block of preformatted text. This element is commonly used to preserves spaces, line breaks, tabs, and other formatting characters in source markup that web browsers would otherwise ignore.

Text within the <pre> element is typically rendered by the browsers in a monospace (fixed-width) font, such as Courier, but this style can be overridden using CSS.

The following table summarizes the usages context and the version history of this tag.

Placement: Block
Content: Most inline tags and text
Start/End Tag: Start tag: required, End tag: required
Version: HTML 3.2, 4, 4.01, 5

Note: By default, only the first space is honored; subsequent spaces — unless specified using the &nbsp; entity — aren't rendered by the browsers.


Syntax

The basic syntax of the <pre> tag is given with:

HTML / XHTML: <pre> ... </pre>

The example below shows the <pre> tag in action.

<pre>
The pre
    element preserves      spaces,
        line-breaks, tabs...
</pre>

Tag-Specific Attributes

The following table shows the attributes that are specific to the <pre> tag.

Attribute Value Description
width number Obsolete Specifies the maximum number of characters per line.

Global Attributes

Like all other HTML tags, the <pre> tag supports the global attributes in HTML5.


Event Attributes

The <pre> tag also supports the event attributes in HTML5.


Browser Compatibility

The <pre> tag is supported in all major modern browsers.

Browsers Icon

Basic Support—

  • Firefox 1+
  • Google Chrome 1+
  • Internet Explorer 2+
  • Apple Safari 1+
  • Opera 4+

Further Reading

See tutorial on: HTML Text Formatting.

See CSS property: white-space.

Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties