首页 > 解决方案 > 如何在 html 页面中展示 html 代码?

问题描述

当我这么说的时候,我的意思是我如何让一段特定的代码不作为实际网站的一部分显示,而是作为演示给其他人看?

标签: html

解决方案


有多种方法可以做到这一点

  1. 您可以使用<pre></pre>标签
<pre>
   your-code
</pre>
  1. 使用特殊<code>标签
<pre>
  <code>
    your-code
  </code>
</pre>
  1. 您可能希望在其中使用 HTML 代码
<![CDATA[<your-code>]]>
  1. 使用任何语法高亮库,例如prettifysyntaxhighlighter

推荐阅读