我有一些HTML脚本,我想让它显示在网页中,如代码选项:
<a href="#">test</a>
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
SLa*_*aks 19
您需要对文本进行HTML转义,因为您可以轻松判断是否查看了此页面的HTML源代码:
<div class="post-text">
<p>I have some HTML that I would like to make it appear like the code option here</p>
<pre><code><a href="#">test</a>
</code></pre>
<p>How can I do it?</p>
</div>
Run Code Online (Sandbox Code Playgroud)
您需要对尖括号等进行编码才能在页面上显示.
您可以在html中手动执行此操作:
<a href="#">test</a>
Run Code Online (Sandbox Code Playgroud)
哪里:
< = <
> = >
Run Code Online (Sandbox Code Playgroud)
对于其他字符,这里是一个字符代码表:http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
| 归档时间: |
|
| 查看次数: |
33975 次 |
| 最近记录: |