How to escape everything in a block in HTML

吃可爱长大的小学妹 提交于 2019-12-03 17:50:16

问题


I seem to recall that there is an HTML tag that escapes absolutely everything inside it except the matching closing tag. Kind of like <plaintext> but not fundamentally broken.


回答1:


<xmp> is the tag you are looking for:

<xmp>some stuff <tags></tags> too</xmp>

But, since it's depricated, the best you can get is <pre>.




回答2:


You need to use <pre><code> ... </code></pre>.

<xmp> is deprecated and should not be used. See http://www.htmlcodetutorial.com/_XMP.html.




回答3:


There is also the XML CDATA:

<![CDATA[stuff that is <tag>never</tag> parsed]]>

Whether this works in an HTML document is probably up to the browser. However, it should certainly work in an XHTML document.



来源:https://stackoverflow.com/questions/373324/how-to-escape-everything-in-a-block-in-html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!