Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[html] 第87天 举例说明如何原样输出HTML代码,不被浏览器解析? #600

Open
haizhilin2013 opened this issue Jul 11, 2019 · 7 comments
Labels
html html

Comments

@haizhilin2013
Copy link
Collaborator

第87天 举例说明如何原样输出HTML代码,不被浏览器解析?

@haizhilin2013 haizhilin2013 added the html html label Jul 11, 2019
@Wendy0828
Copy link

  1. 使用pre标签
  2. 转义...

@dondonZh
Copy link

方法1: 如果是有空格和回车这样的特殊字符的简单文本, 在文本外加

标签

方法2:用<textarea></textarea>标签

方法3:把html的<>转换成特殊字符 (例:< div > 内容 < /div >)

方法4:如果是html内容、javascript、xml或其他特殊内容,使用<xmp></xmp>标签

方法5:如果是在代码中执行时要显示或打印等可以使用
摘自博客

@xiangshuo1992
Copy link
Contributor

precode

@nowherebutup
Copy link

使用pre标签

@JiangXue93
Copy link

JiangXue93 commented Jul 12, 2019

<xmp></xmp>标签已被废弃,建议不要使用了。
推荐使用<pre>或者<code>,需要注意的是将内容中的"<"转义为"&lt;",以防止被浏览器当作正常标签解析。

摘自MDN

@Pangnz
Copy link

Pangnz commented Jul 17, 2019

	<textarea rows="" cols="" style="border: none;resize: none;width: 100%;"><div class="div2">2</div></textarea>

@MrZ2019
Copy link

MrZ2019 commented Mar 3, 2021

用<textarea></textarea>标签

使用pre标签

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
html html
Projects
None yet
Development

No branches or pull requests

8 participants