如何将HTML标签显示为文本 [英] How to display HTML tags as text
问题描述
如何在 .html
页面中显示HTML标签,而不必让浏览器尝试执行标签中的任何内容。
您必须使用使用转义版本。例如<
变成& lt;
(不含引号)和&
变成& amp;
。
您应该能够找到完整的转换列表。
示例代码片段:
& lt; a href = http://google.com &安培; GT;谷歌&安培; LT; / A&安培; GT;
是转义版本:
< a href =http://google.com> Google< / a>
编辑:
标准列表实体: http://www.w3.org/TR/html4/sgml/entities .html
维基百科artcile: http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
How can I display HTML tags in a .html
page without having my browser try to execute whatever is in the tag.
You must use use the escaped version. For example <
becomes <
(no quotes) and &
becomes &
.
You should be able to find a full list of transformations.
An example snippet:
<a href="http://google.com">Google</a>
is the escaped version of:
<a href="http://google.com">Google</a>
Edit:
The standard's list of entities: http://www.w3.org/TR/html4/sgml/entities.html
A Wikipedia artcile on it: http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
这篇关于如何将HTML标签显示为文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!