如何将HTML标签显示为文本 [英] How to display HTML tags as text

查看:446
本文介绍了如何将HTML标签显示为文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 .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 &lt; (no quotes) and & becomes &amp;.

You should be able to find a full list of transformations.

An example snippet:

&lt;a href="http://google.com"&gt;Google&lt;/a&gt;

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆