如何将 html 代码添加到网站但不将其实际转换为代码?
我不知道如何描述这个。基本上我想在我的网站中显示我的网站的编码。。所以我不确定要贴什么标签。我已经做了一些谷歌搜索,但我什至不确定我在谷歌搜索什么。我找到了这些标签,但似乎没有一个起作用。我发现脚本标签不是我需要的,而代码标签却没有达到我想要的效果。有人知道该怎么办吗? 提前致谢
I'm not sure how to describe this one. Basicly I want to show the coding of my website, in my website. So I'm not sure what tag to put. I've done some googling but i'm not even sure what I'm Googleing. I've found these tags, but none of them seemed to work. I found the script tag which I found out isn't what I needed and the code tag but that didn't do what I wanted. Anyone know what to do?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
将
<
写为<
并将>
写为>
(它们的字符实体等价物)。这将防止浏览器将它们解释为标签。因此,不要
写
“乏味,但必要”。从技术上讲,
>
仅当其前面有<
某处时才被视为标记结束符,因此您可能能够只需执行<
-> 就可以了<
,但以实体格式写出这两个字符更安全。完成后,您可能需要使用
write the
<
as<
and the>
as>
(their character entity equivalents). This will prevent the browser from interpreting them as tags.So instead of
You'd write
Tedious, but necessary. Technically speaking, a
>
is only seen as a tag closer if it was preceded by a<
somewhere, so you MIGHT be able to get by with just doing<
-><
, but it's safer to write out both characters in entity format.Once that's done you may want to wrap it with the
<pre>
tag (as in preformatted) which will cause the spacing and line breaks to be rendered just as they appear in your source code.对每个适用的符号使用 HTML 实体。或者,您可以使用 PHP 并通过 htmlentities 运行字符串。
Utilize the HTML entity for each applicable symbol. Alternatively, you could use PHP and run the string through htmlentities.
我不确定你是否可以用一个简单的标签来做到这一点,但我使用这个 php 库将我的代码转换为漂亮的 html 代码
http://qbnz.com/highlighter/
I am not sure if you can do it with a simple tag, but I use this php library to convert my code to nice html code
http://qbnz.com/highlighter/
看看这个,我想这可能就是您正在寻找的。
http://code.google.com/p/google-code-prettify/
take a look at this, i think it may be what you are looking for.
http://code.google.com/p/google-code-prettify/