在HTML正文中编码引号? [英] Encode quotes in HTML body?

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

问题描述

我应该编码引号(例如和 - > & rdquo; & rsquo; )(例如将< p>转换为Matt的东西< / p> < p> Matt& rsquo; s Stuff< p> )?我的印象是,我应该,但一个同事说这是没有什么大不了,我很可疑,但我找不到任何东西,说它是verboten。

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 verboten. Am I mistaken? Is it a best-practice to encode? Or is it simply useless?

推荐答案

编码引号()是一个很好的编码引擎在实际中只需要在一个属性内部,然而为了HTML代码是正确的(通过HTML验证),你应该总是编码引号为& quot;

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;.

Apostrophes(')不需要在HTML中转义。在XHTML中,它们应该编码为&';

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

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆