本文比较了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 & space, html tags etc displayed natively. However, note that & (&) will not act as an escape char.. Eg: <u>(text)</u> 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>
参考资料
- https://stackoverflow.com/questions/4611591/code-vs-pre-vs-samp-for-inline-and-block-code-snippets
- https://stackoverflow.com/questions/16065677/what-is-difference-between-pre-and-code-html-tag
- https://www.cnblogs.com/lizonghui/archive/2012/09/18/2692355.html
-- EOF --
本文最后修改于5年前 (2019-07-13)