HTML <plaintext> Element

The <plaintext> element was an early HTML element that caused the remainder of a document to be treated as plain text rather than HTML markup. After a browser encountered the element, HTML tags that followed were displayed as text instead of being interpreted as elements.

Historical Syntax

Early HTML documents could contain markup similar to the following:

<plaintext>
<h1>This is displayed as text</h1>
<p>The browser does not interpret these tags as HTML.</p>

Once the browser encountered <plaintext>, the remainder of the document was treated as text. Even markup that looked like HTML elements was displayed literally rather than being parsed normally. This code is shown for historical reference only and should not be used in modern HTML.

Attributes

The <plaintext> element did not have any standardized element-specific attributes. Its historical behavior was triggered simply by the presence of the element in the document.

Historical Use

The <plaintext> element dates back to the earliest versions of HTML. It provided a simple way to include text that should be displayed exactly as text rather than interpreted as HTML markup.

One unusual characteristic of <plaintext> was that it effectively consumed everything remaining in the document. It did not operate like a normal container with meaningful opening and closing tags. Once plain-text processing began, markup appearing afterward was no longer interpreted as normal HTML.

This made the element useful for some very early documents, but it also made it extremely inflexible. Authors could not simply return to normal HTML markup later in the same document.

Why It Became Obsolete

The <plaintext> element did not fit the structured element model that HTML developed into. Changing how the browser interpreted everything remaining in the document made it difficult to combine plain-text examples with ordinary webpage content.

HTML provides more controlled ways to display preformatted text and code. Characters that have special meaning in HTML can also be represented with character references, allowing markup examples to appear as text without disabling HTML parsing for the rest of the document.

These methods allow authors to display source code and other preformatted content while keeping the surrounding document valid, structured, and easy to style.

Modern Alternative

Use the <pre> element when whitespace and line breaks should be preserved. When the content represents computer code or HTML markup, place a <code> element inside it:

<pre><code>&lt;h1&gt;HTML Example&lt;/h1&gt;
&lt;p&gt;This markup is displayed as text.&lt;/p&gt;</code></pre>

The less-than and greater-than characters are written as &lt; and &gt; so the browser displays the HTML tags rather than interpreting them as elements.

This approach limits the preformatted code to the intended section while allowing the rest of the HTML document to continue normally.

Play in Editor

Legacy Browser Support

The <plaintext> element is obsolete, but browsers may continue to recognize its historical parsing behavior for compatibility with old webpages. When recognized, content following the element can be treated as plain text through the end of the document.

This legacy behavior does not make <plaintext> valid for use in modern HTML. Existing uses should be replaced with structured HTML such as <pre> and <code>, with special HTML characters represented by character references when necessary.

For detailed legacy browser compatibility information, see Can I Use: HTML <plaintext> Element .

The modern <pre> element preserves whitespace and line breaks, while the <code> element identifies computer code. The obsolete <listing> and <xmp> elements were also historically used for displaying preformatted or literal text.

Specifications

The <plaintext> element is listed as an entirely obsolete, non-conforming feature in the WHATWG HTML Living Standard . Authors should use structured HTML and character references when displaying markup as text.