<plaintext>
For guidance, refer to the compatibility table below. Keep in mind that this feature may stop working at any time.
plaintext tag
The <plaintext>
tag instructs the browser to treat its content as plain text, ignoring any HTML tags. The content appears in a monospaced font, which can also be applied to other elements using the CSS font-family
property with the monospace
value.
<plaintext>
element in HTML renders all content after its opening tag as plain text, treating it as unformatted and ignoring any subsequent HTML. This element does not require a closing tag, as everything following it is interpreted as raw text.Attributes
The <plaintext>
tag supports global attributes.
See also
- The
<pre>
and<code>
elements as alternatives. - The
<listing>
and<xmp>
elements, which are similar to<plaintext>
but are also obsolete.
<plaintext>
tag has been obsolete since HTML2 and was never consistently supported across browsers. Some browsers that recognize it may treat it similarly to the <pre>
tag while still interpreting HTML content inside it.If
<plaintext>
is the first element in a document (excluding non-displayed elements like <head>
), the page should not use HTML at all. Instead, serve the content as a plain text file with the text/plain
MIME type.Recommended Alternatives:
Conclusion
The <plaintext>
tag in HTML has been obsolete since HTML2 and is no longer recommended due to inconsistent browser support. For displaying raw text, it's better to use the <pre>
tag, which preserves whitespace and formatting, or the <code>
tag for representing code. Applying a monospaced font via CSS is also a viable alternative. These modern solutions provide better compatibility, clarity, and semantic meaning while ensuring that your content is displayed correctly across different browsers.