HTML <pre> Element Reference

The HTML <pre> element preserves whitespace and displays preformatted text as it appears in the source.

<pre>

HTML <pre> Element Reference

The HTML <pre> element preserves whitespace and displays preformatted text as it appears in the source.

Categories

  • Flow content
  • Palpable content

Tag omission

Neither the start tag nor the end tag may be omitted.

Content model

  • Phrasing content

Attributes

Examples

Source-code block

Combine pre with code when the preserved text is source code.

<pre><code>const answer = 42;</code></pre>

Related references

Description

The HTML <pre> element preserves whitespace and displays preformatted text as it appears in the source.

References

  1. HTML Living Standard: The pre element
  2. MDN: <pre> — The Preformatted Text element

Similar or alternative tools

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies