与<pre> tag

时间:2015-07-28 22:07:38

标签: html pre

I just want to know if there's an opposite tag for <pre>. Like when the elements are interpreted as plain text, I want the browser to interpret it as HTML tags.

For some reason, what I get is the plain text with the tags in it but the browser doesn't interpret it.

Thanks.

2 个答案:

答案 0 :(得分:0)

There is no opposite of the pre. Somewhere, you are html-encoding the text with the html tags in it, causing them to become escaped, and thus, displayed as text, rather than interpreted as html.

You can html-decode the text to turn text-tags into html tags again.

Could you show us the code/software you're using to create the tags, or at least the language you are using so we can show you how to do it?

答案 1 :(得分:0)

<pre> 没有相反的标签,但您可以使用 JavaScript,并将“HTML 文本”设置为某个元素的 innerHTML 属性。

例如:

window.onload = function() {
  var myHtmlText = "<strong>HaHaHa</strong>";
  document.getElementById("code-container").innerHTML = myHtmlText;
}
<span>Hello! </span>
<span id="code-container"></span>

注意:在渲染目标元素后使用它很重要,使用 window.onload

相关问题