What was the <XMP> tag used for?

Does anyone remember the XMP tag?

What was it used for and why was it deprecated?


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


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 xmp.html. View the source to see the tags.


    XMP does some things than PRE does not support (as a long time HTML/CSS/JavaScript author you'll just have to trust me on this, or not). I still depend on XMP, there is -NO- substitute (PRE is -not- a substitute no matter what anyone says... not even close.)

    链接地址: http://www.djcxy.com/p/30432.html

    上一篇: 在Javascript中使用长字符串的最佳方式是什么?

    下一篇: 什么是<XMP>标签用于?