几种HTML标签的比较:textarea / xmp / pre / samp / code

     0评论

本文比较了textarea、xmp、pre、samp、code这几种HTML标签在“保持原格式”上的差异。

PRE:

The PRE element tells visual user agents that the enclosed text is "preformatted". When handling preformatted text, visual user agents:

May leave white space intact.
May render text with a fixed-pitch font.
May disable automatic word wrap.
Must not disable bidirectional processing.

CODE:
Designates a fragment of computer code.

Compared: TEXTAREA, XMP, PRE, SAMP, CODE

Note that CSS can be used to override default fixed space fonts in each or all these.

XMP: Example text with Newlines, tabs &amp; space, html tags etc <b>displayed natively</b>. However, note that &amp; (&amp;) will not act as an escape char.. Eg: &lt;u&gt;(text)&lt;/u&gt;
PRE: Example text with Newlines,
tabs & space,
  html tags etc are interpreted, not displayed.
    However, note that & still acts as an escape char..
      Eg: <u>(text)</u>

SAMP: Example text with Newlines,
tabs & space,
html tags etc are interpreted, not displayed.
However, note that & still acts as an escape char..
Eg: <u>(text)</u>

CODE: Example text with Newlines,
tabs & space,
html tags etc are interpreted, not displayed.
However, note that & still acts as an escape char..
Eg: <u>(text)</u>

参考资料

-- EOF --

本文最后修改于6年前 (2019-07-13)

差评不太行一般挺好非常不错 (No Ratings Yet)
读取中...
发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址