简体   繁体   English

HTML源代码显示

[英]Html Source Code Displaying

我想显示HTML页面的源代码,因为它是写在记事本上的,请问如何防止浏览器解析代码并显示HTML页面的原始源代码?

You can use a Syntax Highlighter like this one: https://code.google.com/p/syntaxhighlighter/ 您可以像这样使用语法突出显示器: https : //code.google.com/p/syntaxhighlighter/

Or you can use <code></code> 或者您可以使用<code></code>

So <div class="helloworld"></div> would become: 因此<div class="helloworld"></div>将变为:

<code>&lt;div class="helloworld"&gt;&lt;/div&gt;</code>

&lt and &gt stands for the less than and greater than brackets. &lt和&gt表示小于和大于括号。

you can use "pre" tag to display source code: 您可以使用“ pre”标签显示源代码:

<pre>code stuff</pre>

if you want to use class name with the syntax highlighter you can try as below: 如果要在语法突出显示中使用类名,可以尝试以下操作:

<pre><code class="xyz">headerFunction</code></pre> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM