What was the <XMP> tag used for?

HtmlTags

Html Problem Overview


Does anyone remember the XMP tag?

What was it used for and why was it deprecated?

Html Solutions


Solution 1 - Html

XMP and PRE differ. Content within PRE tags is formatted as follows:

  • Content is shown with a fixed font,
  • All whitespace is preserved, and
  • Each line break begins a new line.

If you want to include special characters such as <, > and & within PRE tags, they must be escaped so that they are not subject to special interpretation by the browser.

In contrast, content within XMP tags does not need to be escaped.

The only character sequence that cannot be included within XMP tags is the XMP end tag (</XMP>).

XMP is still supported by the browsers I have tested. You can try it with http://dadinck.x10.mx/xmp.html">xmp.html</a>;. View the source to see the tags.

Solution 2 - Html

A quick Google search on W3C reveals that XMP was introduced for displaying preformatted text in HTML 3.2 and earlier. When W3C deprecated the XMP tag, it suggested using the PRE tag as a preferred alternative.

Update: http://www.w3.org/TR/REC-html32#xmp, http://www.w3.org/MarkUp/html-spec/html-spec_5.html#SEC5.5.2.1

Solution 3 - Html

XMP does some things that PRE does not support. I still depend on XMP, there is no substitute.

Solution 4 - Html

<xmp> is used with strapdown.js in formatting markdown notation. The name strapdown combining the terms bootstrap and markdown.

<!DOCTYPE html>
<html>
  <title>Example</title>
  <xmp theme="united">
## Example

 - note one
 - note two
 - note three
  </xmp>
  <script src="http://strapdownjs.com/v/0.2/strapdown.js"></script>
</html>

Solution 5 - Html

I still use the xmp tag for debugging var_dump(); in PHP. I just can't remember to use the pre tag for some reason.

I think it doesn't really matter because if you really want to output text, you should use textarea with the readonly attribute.

Solution 6 - Html

See http://www.w3.org/Bugs/Public/show_bug.cgi?id=12235

For HTML5. it was, according to the HTML5 editor (comments 11 and 12), a very close call either way.

Solution 7 - Html

I used <textarea>, which puts the html code into a neat box and clearly defines the code as different from the text before or after.

<textarea><b>boldtext</b><textarea>

Solution 8 - Html

Still works to show raw html - if you use it in script, break the start tag.

var stuff='<xmp'+'>this is shown as is<br/>hello</xmp>';
document.getElementById("x").innerHTML=stuff;

<div id="x"></div>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionGateKillerView Question on Stackoverflow
Solution 1 - HtmldadinckView Answer on Stackoverflow
Solution 2 - Htmlgraham.reedsView Answer on Stackoverflow
Solution 3 - HtmlThomasView Answer on Stackoverflow
Solution 4 - HtmlnoobninjaView Answer on Stackoverflow
Solution 5 - HtmlAdam FView Answer on Stackoverflow
Solution 6 - HtmlAlohciView Answer on Stackoverflow
Solution 7 - HtmlPhil BusbyView Answer on Stackoverflow
Solution 8 - HtmlmplungjanView Answer on Stackoverflow