HTML <plaintext> Tag

Beginner
5 min read
Updated: Oct 2026
4 examples
Live preview

Definition and Usage

The <plaintext> element once made everything after its start tag raw text, ignoring following HTML. There was no closing tag.

Do not use it. Prefer <pre> for blocks or <code> for inline samples. Escape <, >, and &. For a whole plain-text document, serve text/plain instead of HTML.

Deprecated · Obsolete.

Deprecated since HTML 2. Never consistent across browsers. Some engines may treat it like a <pre> that still parses HTML. Avoid in every new project.

Study-only examples.

Legacy snippets exist so you can recognize old markup. Prefer the pre / code versions.

HTML Syntax

syntax.html
<plaintext> raw text to end of file…

Historical form only — start tag, no end tag. Prefer this modern equivalent:

prefer.html
<pre><code>&lt;p&gt;Hello&lt;/p&gt;</code></pre>

Attributes

<plaintext> had no element-specific attributes. Only globals applied historically:

AttributeDescriptionTry it
classStyle hook (prefer on modern pre / code)Try it
idUnique target for links (prefer on modern elements)Try it
langLanguage of the text when it differs from surrounding contentTry it

Global Attributes

The <plaintext> tag also supports the Global Attributes in HTML.

Live Preview

Compare a safe modern sample with how engines often treat leftover plaintext markup today.

Prefer escaped pre/code. Legacy plaintext is unsafe and obsolete.

Result
<p>Hello</p>

Modern pre + code with escaped angle brackets.

HTML Examples

Short study snippets. Use Try It Yourself for a live editor. Prefer Examples 2–4 in real projects.

Example 1 — Legacy plaintext (Study Only)

Historically, everything after the start tag was treated as raw text. Do not ship this.

HTML
<plaintext>
This was meant to be raw text.
<p>Tags after plaintext were ignored historically.</p>
Try It Yourself

How It Works

  1. Open <plaintext> with a start tag only.
  2. Know the old rule: following markup was treated as text (no end tag).
  3. Expect inconsistency — modern engines may not match that history.
  4. Replace immediately with pre/code and escapes.

Example 2 — pre with Escaped HTML (Preferred)

Show tags as text by escaping special characters inside <pre>.

HTML
<pre>
&lt;p&gt;Hello&lt;/p&gt;
</pre>
Try It Yourself

How It Works

  1. Wrap the block in <pre> to keep whitespace.
  2. Write &lt; and &gt; instead of raw < / >.
  3. Escape & as &amp; when needed.
  4. Keep the rest of the page as normal HTML after </pre>.

Example 3 — Inline code

For short snippets inside a sentence, use <code>.

HTML
<p>
  Use the <code>&lt;pre&gt;</code> element for code blocks.
</p>
Try It Yourself

How It Works

  1. Keep prose in <p>.
  2. Wrap the token in <code>.
  3. Escape angle brackets inside the sample.
  4. Style with CSS (font-family: monospace) if you want a fixed-width look.

Example 4 — pre + code (Best Practice)

Combine both: pre for whitespace, code for semantics.

HTML
<pre><code>function hello() {
  console.log("Hi");
}</code></pre>
Try It Yourself

How It Works

  1. Open <pre> for the block.
  2. Nest <code> for computer code semantics.
  3. Paste the sample; escape < / > / & when the sample is HTML.
  4. Close both tags so the rest of the page stays normal HTML.

Edge Cases & Pitfalls

Most plaintext problems come from copying historical behavior into modern pages.

obsolete

Never consistent

Deprecated since HTML 2. Engines differed then and still differ now. Never build new UI on it.

danger

No closing tag

Historical design swallowed the rest of the document. That can break layouts and scripts if an engine still approximates the old rule.

escape

Escape in pre/code

To show HTML as text, use &lt;, &gt;, and &amp;. Do not rely on a raw-text element.

mime

Whole-document plain text

If the entire response should be plain text, serve Content-Type: text/plain — do not wrap an HTML page in plaintext.

related

Also obsolete: xmp, listing

Similar historical raw-text ideas. Prefer pre / code for all of them.

Browser Support

The <plaintext> element is legacy HTML. It is not a Node.js, Deno, or Bun API.

✓ Deprecated · Obsolete

<plaintext>

Never reliably standardized. Some browsers may map it toward pre-like rendering. Prefer pre and code with escaped characters.

— Do not use in new work
Google Chrome Legacy
Non-standard / remapped
Mozilla Firefox Legacy
Non-standard / remapped
Apple Safari Legacy
Non-standard / remapped
Microsoft Edge Legacy
Non-standard / remapped
Opera Legacy
Non-standard / remapped
Samsung Internet Legacy
Non-standard / remapped
Internet Explorer Legacy
Historical
<plaintext> Obsolete (use pre/code)

Bottom line: Recognize plaintext in very old markup, then replace it with pre/code. Never ship new pages that depend on it.

Key Takeaways

  • Status: <plaintext> is obsolete — avoid in new HTML.
  • History: start tag only; following HTML was meant to be raw text.
  • Replace with: pre, code, and escaped < / > / &.
  • Whole file: use text/plain, not an HTML element.

One line: recognize <plaintext> in old pages; show text samples with pre/code.

Default CSS Settings

There is no modern standard stylesheet for <plaintext>. Engines that remap it often behave like pre:

prefer.css
/* Prefer styling modern elements */
pre, code {
  font-family: monospace;
}

pre {
  white-space: pre;
}

Apply font-family: monospace with CSS when you want a fixed-width look — not via obsolete tags.

Frequently Asked Questions

Historically, plaintext made everything after its start tag raw text and ignored following HTML. There was no closing tag. It is obsolete.
No. It has been deprecated since HTML 2 and is obsolete. Do not use it in new projects.
Use pre for preformatted blocks, or code for inline code. Escape <, >, and & so browsers do not parse them as markup. For a whole plain-text document, serve text/plain.
Support was never consistent. Some engines may treat it like a pre that still interprets HTML. Do not rely on it.
No. text/plain is an HTTP content type for an entire response. The plaintext element was obsolete HTML markup inside a page.
Put the sample in pre or code and escape characters: &lt; for <, &gt; for >, and &amp; for &.

Next: pre

Learn the modern preformatted text element properly.

pre tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful