【发布时间】:2020-06-13 21:21:26
【问题描述】:
当我这么说的时候,我的意思是我如何让一段特定的代码不作为实际网站的一部分显示,而是作为演示给其他人看?
【问题讨论】:
标签: html
当我这么说的时候,我的意思是我如何让一段特定的代码不作为实际网站的一部分显示,而是作为演示给其他人看?
【问题讨论】:
标签: html
有多种方法可以做到这一点
<pre></pre>标签<pre>
your-code
</pre>
<code>标签<pre>
<code>
your-code
</code>
</pre>
<![CDATA[<your-code>]]>
【讨论】:
你必须使用:
<pre> - 用于显示 html 文本的预格式化标签&lt; - 小于标记代替代码中的 标记
&gt; - 大于代码中的 > 标记。&lt;div&gt; 应替换为&lt;div&gt;
简单的例子
<pre>
<!DOCTYPE html>
<html>
<body>
<h1>The code element</h1>
<p>The HTML <code>button</code> tag defines a clickable button.</p>
<p>The CSS <code>background-color</code> property defines the background color of an element.</p>
</body>
</html>
</pre>
【讨论】:
<pre>
<code>
you code here
</code>
</pre>
【讨论】: