<xmp>

The HTML <xmp> element, which is now obsolete, was used to display preformatted text with visible HTML tags. Today, the <pre> element or code escaping techniques serve as modern alternatives.

xmp tag

The <xmp> tag displays the text between its opening and closing tags as plain text, without rendering any HTML inside, and uses a monospaced font.

Syntax

index.html
<xmp>
  Your content goes here, including <tags> that won't be interpreted.
</xmp>

xmp Demo

  • As <xmp> is deprecated, it’s advisable to avoid using it in current web development practices.
&lt;p&gt;This is some HTML code that will not be rendered as a paragraph.&lt;/p&gt;
index.html
<xmp>
  <p>This is some HTML code that will not be rendered as a paragraph.</p>
</xmp>
In modern HTML, the <pre> element, combined with <code>, serves as a preferred alternative:
    
      

This is how you'd display code nowadays.

index.html
<pre>
  <code>
    <p>This is how you'd display code nowadays.</p>
  </code>
</pre>

Attributes

This element only supports global attributes that apply to all HTML elements.

DOM Interface

This element implements the HTMLElement interface.

See also

  • The <pre> and <code> elements as alternatives.
  • The <plaintext> and <listing> elements, which are similar to <xmp> but also obsolete.

Conclusion

The <xmp> tag in HTML is deprecated and should no longer be used in modern web development. It was originally used to display text as plain text, without interpreting HTML inside it. Today, the <pre> and <code> tags are recommended alternatives for displaying code or preformatted content. These modern elements provide better structure and are more aligned with current HTML standards.