本文介绍了如何在HTML正文中编码引号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该对引号进行编码(例如和'-> & rdquo; 和’ )(例如,将< / p>马特的东西< / p> 转换为< p>马特’ s东西< / p> )?我当时有应有的印象,但一位同事说这没什么大不了的。我很怀疑,但是我找不到任何禁止这样做的东西。我弄错了吗?这是编码的最佳实践吗?还是根本没用?

Should I encode quotes (such as " and ' -> &rdquo; and &rsquo;) in my HTML body (e.g. convert <p>Matt's Stuff</p> to <p>Matt&rsquo;s Stuff</p>)? I was under the impression I should, but a co-worker said that it was no big deal. I'm dubious but I can't find anything that says it is forbidden. Am I mistaken? Is it a best-practice to encode? Or is it simply useless?

推荐答案

编码引号()是在实践中,仅当'位于属性内时才需要,但是为了使HTML代码正确(通过HTML验证),您应始终将引号编码为&

Encoding quotation marks (") is in practice only needed if the're inside an attribute, however for the HTML code to be correct (passing HTML validation), you should always encode quotation marks as &quot;.

撇号(')不需要在HTML中转义。在XHTML中,它们应被编码为&’。

Apostrophes (') don't need escaping in HTML. In XHTML they should be encoded as &apos;.

这篇关于如何在HTML正文中编码引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 22:36