html - 如何在 <code>/<pre> 标签中按字面显示 <div> 标签?

标签 html blogger

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

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

除 HTML 外,它对所有内容都有效。知道如何实现这一目标吗?谢谢。

最佳答案

Unfortunately it doesn't work with HTML tags.

<code>表示“这是代码”,<pre>表示“此标记中的空白很重要”。两者都不意味着“不应将此元素的内容视为 HTML”,因此两者都可以完美地工作,即使它们并不代表您想要的意思。

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

如果你想渲染一个<字符然后使用 &lt; , 与 &gt;对于 >&amp;对于 & .

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

关于html - 如何在 <code>/<pre> 标签中按字面显示 <div> 标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56204613/

相关文章:

blogs - 我的 <div> 在 "min-width"和 "max-width"之间选择了最大宽度

html - 如何在新标签页和 Nofollow 中打开链接

html - Angular:如何使用元服务添加或更新元标签以进行 SEO

javascript - jquery 鼠标事件的问题

javascript - jquery onchange 高亮表格区域

javascript - 将选项卡链接移至博客的右侧

博主b :if statement

css - 直接包含 SVG 时的辅助功能

html - 使用 class = row 操作第二个 div

javascript - 在 Blogger/Blogspot 中多次重新加载同一页面会降低跳出率吗?