简体   繁体   English

如何转义HTML元素,以便输入 <div> 在HTML文章中

[英]How do I escape an HTML element so I can type the term <div> in an HTML write-up

I'm doing an HTML write up for a colleague that is going to go on our intranet site, but I have to write the instructions in the HTML itself. 我正在为将要在我们的Intranet网站上访问的同事编写HTML,但是我必须在HTML本身中编写说明。 I need to write the word <div> in the instructions, but I need to have it so the '' displays as the word , not an actual div. 我需要在说明中写出<div>字,但我需要使用它,以便''显示为单词,而不是实际的div。

Because I'm writing it directly inside the HTML, I need a way of somehow escaping the HTML, but keep the word and it's arrow brackets. 因为我是直接在HTML内部编写代码,所以我需要一种以某种方式转义HTML的方法,但要保留单词及其箭头括号。

How do I go about doing this? 我该怎么做呢?

EXAMPLE

<p>This is some text followed by the word <div>, but not an actual div.</p>

Replace < with &lt; <替换为&lt; and > with &gt; >&gt; Those are HTML Entities which can replace real tags. 这些是可以替换真实标签的HTML实体 That way, it'll apear as <div> althought it isn't actually a div. 这样,它实际上会显示为<div>尽管它实际上不是div。

 <p>This is some text followed by the word &lt;div&gt;, but not an actual div.</p> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM