W3docs

HTML <xmp> Tag

The <xmp> renders text between the start and end tags without interpreting the HTML in between and using a monospaced font.

The <xmp> element renders text between the start and end tags without interpreting any HTML inside it, and displays it using a monospaced font.

Danger

The <xmp> tag is obsolete and is not supported in HTML5. Use the <pre> element instead. Unlike <xmp>, <pre> interprets HTML tags inside it, so you must use &amp;lt; and &amp;gt; instead of < and > characters to make sure they are not interpreted as markup.

Syntax

The <xmp> tag comes in pairs. The content is written between the opening (<xmp>) and closing (</xmp>) tags.

Example of the HTML <xmp> tag

HTML <xmp> Tag

<!DOCTYPE html>
<html>
  <head>
    <title>The title of the document</title>
  </head>
  <body>
    <xmp> This is a preformatted text.
      All characters in this area have the same width,
      and the spaces and line breaks within this element are shown as typed.
    </xmp>
  </body>
</html>

Result

xmp tag example

Attributes

The <xmp> tag also supports the Global Attributes.

Practice

Practice

What is the characteristic of the HTML <xmp> tag?