📝 The <plaintext>
Tag in HTML: Displaying Raw Text from Here Onward
The <plaintext>
tag is a deprecated HTML element that tells the browser to render all the following content as plain text, ignoring any HTML markup after it.
📌 What Is the <plaintext>
Tag?
- The
<plaintext>
tag causes the browser to treat everything that follows as raw text, including what would normally be HTML tags. - It was introduced in early versions of HTML but is obsolete and no longer supported in modern standards.
- The tag has no closing tag — everything after it is plain text until the end of the document.
✅ Basic Syntax
<plaintext>
<h1>This will not be a heading</h1>
<p>But just plain text</p>
🧩 What Happens?
Instead of rendering the <h1>
and <p>
as HTML elements, the browser displays the tags themselves as text.
🧪 Example
<!DOCTYPE html>
<html>
<body>
<p>This is a normal paragraph.</p>
<plaintext>
<h1>This looks like code</h1>
<p>And this too</p>
</body>
</html>
Rendered output:
This is a normal paragraph.
<h1>This looks like code</h1>
<p>And this too</p>
⚠️ Important Notes
<plaintext>
is non-standard and deprecated; avoid using it in modern HTML.- Modern alternatives include using
<pre>
,<code>
, or escaping HTML entities to show code. - The tag is not supported in many browsers and can cause unexpected results.
🔄 Modern Alternative: Showing Code Safely
Use <pre>
and <code>
, with escaped HTML characters:
<pre><code>
<h1>This looks like code</h1>
<p>And this too</p>
</code></pre>
🏁 Summary
The <plaintext>
tag is an old way to display everything following it as raw text, including HTML tags. It’s obsolete and should be avoided in favor of modern, standardized tags like <pre>
and <code>
.