Signup/Sign In

HTML Pre Tag

In HTML, the <pre> tag stands for preformatted text.

  • It is exactly present on the Web page as present in an HTML file.

  • The whitespace used inside this tag is displayed as written.

  • The text is written in between <pre> tag is displayed in a fixed-width font.

  • Also, it is a Block-Level Element

  • It is recommended to use <pre> tag in case of unusual formatting or if you want to write some piece of computer code.

HTML <pre> Tag Syntax and Usage

The <pre> tag requires both opening (start) tag and closing(end) tag.

Required syntax for the same is given below:

<pre>
....content here
</pre>

HTML <pre> Tag Attributes

The <pre> tag supports both global and event attributes and some of the common attributes are given below:

1. Cols

This attribute is used to contains the preferred count of characters a line should have, also known as a non-standard synonym of width.

2. Width

This attribute is used to contains the preferred count of characters a line should have, this does not have a visual effect.

3. Wrap

It is used to indicate the hint that overflow must happen

HTML <pre> Tag Basic Example

Below we have a basic example for clear understanding of <pre> tag:

Default CSS Settings for HTML <pre> Tag

pre {
  display: block;
  font-family: monospace;
  white-space: pre;
  margin: 1em 0;
}

Browser Support for HTML <pre> Tag

Following browsers support this attribute:

  • Firefox 1+

  • Google Chrome 1+

  • Internet Explorer 2+

  • Safari 1+

  • Opera 4+



About the author:
Aspiring Software developer working as a content writer. I like computer related subjects like Computer Networks, Operating system, CAO, Database, and I am also learning Python.