如何显示< div>在< code> /< pre>标签? [英] How to show <div> tag literally in <code>/<pre> tag?

查看:162
本文介绍了如何显示< div>在< code> /< pre>标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在< pre> 标签内使用< code> 标签来显示代码我的博客博客。不幸的是,它不适用于HTML标签。有没有什么办法在< pre> < div> >< code> 标记,但实际上没有将其解释为HTML?这就是我现在所做的:

 < pre> 
< code>
.class {
color:red;
}
//我希望这个
内的HTML代码< / code>
< / pre>

除了HTML之外,其他所有工作都可以正常工作。任何想法如何实现这一目标?感谢。

解决方案


不幸的是,它不适用于HTML标记。 $ b

< code> 表示This is code,< pre> ; 表示此标记中的空白区域很重要。这两者都不意味着这个元素的内容不应该被视为HTML,所以它们都可以很好地工作,即使它们并不意味着它们的意思。


是否有任何方式在< pre> < div> >或< code> 标签,而无需将其实际解释为HTML?如果你想渲染一个 字符,那么使用& lt; ,其中& gt; > & amp; &



您不能(在现代HTML中)编写标记并将其解释为文本。


I'm using <code> tag inside of a <pre> tag to show code on my blogger blog. Unfortunately it doesn't work with HTML tags. Is there any way to show "<div>" inside of <pre> or <code> tag without actually interpreting it as HTML? This is what I do right now:

<pre>
 <code>
 .class {        
   color:red;
 }
 // I would like HTML code inside this
 </code>
</pre>

Which works ok for everything except HTML. Any idea how to achieve this? Thanks.

解决方案

Unfortunately it doesn't work with HTML tags.

<code> means "This is code", <pre> means "White space in this markup is significant". Neither means "The content of this element should not be treated as HTML", so both work perfectly, even if they don't mean what you want them to mean.

Is there any way to show "<div>" inside of <pre> or <code> tag without actually interpreting it as HTML?

If you want to render a < character then use &lt;, with &gt; for > and &amp; for &.

You can't (in modern HTML) write markup and have it be interpreted as text.

这篇关于如何显示&lt; div&gt;在&lt; code&gt; /&lt; pre&gt;标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆