W3docs

HTML <plaintext> Tag

The content of the <plaintext> tag is represented as an ordinary text without formatting. Tag description and examples of using.

The <plaintext> tag tells the browser that its content must be displayed as ordinary text without formatting. When the parser encounters this tag, it switches to raw text mode and treats all subsequent content in the document as plain text, ignoring any HTML tags.

Danger

The <plaintext> tag is deprecated. Instead, use the <pre> or <code> tags if semantically accurate. A monospaced font can be applied to any HTML element using the CSS font-family property with the monospace generic value.

Danger

If <plaintext> is the first element on the page, the entire document response will be treated as plain text. In this case, serving a text file with the text/plain MIME-type is preferable.

Syntax

The <plaintext> tag is not a void element, but its closing tag is forbidden. The HTML parser stops processing once it encounters the opening tag, effectively consuming the rest of the document as plain text.

Example of the HTML <plaintext> tag:

<!DOCTYPE html>
<html>
 <head>
    <title>Title of the document</title>
 </head>
  <body>
    <p>The tag content looks like this:</p>
    <plaintext>
    <h1>Main title of the document</h1>
    <p>First paragraph of the text</p>
    <h2>Subheading</h2>
  </body>
</html>

Result

plaintext tag example

Attributes

The <plaintext> tag supports the Global Attributes.

Practice

Practice

What is the function of the <plaintext> tag in HTML?