为什么不应该使用`&'来转义单引号? [英] Why shouldn't `'` be used to escape single quotes?
问题描述
如前所述, HTML中的单引号何时成为如此受欢迎?和 Jquery嵌入式引用属性,维基百科条目HTML表示以下内容:
As stated in, When did single quotes in HTML become so popular? and Jquery embedded quote in attribute, the Wikipedia entry on HTML says the following:
单引号字符(')在用于引用属性值时也必须转义为
'
或'
(不应该转义为除了XHTML文档)当它出现在属性值本身内时。
The single-quote character ('), when used to quote an attribute value, must also be escaped as
'
or'
(should NOT be escaped as'
except in XHTML documents) when it appears within the attribute value itself.
为什么不应该要使用&'
另外,& quot;
可以安全使用,而不是"
?
Why shouldn't '
be used? Also, is "
safe to be used instead of "
?
推荐答案
& quot;
正式列出有效的 HTML 4个实体,但&'/ code >不是。
"
is on the official list of valid HTML 4 entities, but '
is not.
从 C. 16。命名角色参考:
命名角色参考
& c $ c $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $作者应该
因此使用'
而不是
&'/ code>在HTML 4
用户代理中按预期工作。
The named character reference
'
(the apostrophe, U+0027) was introduced in XML 1.0 but does not appear in HTML. Authors should therefore use'
instead of'
to work as expected in HTML 4 user agents.
这篇关于为什么不应该使用`&'来转义单引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!