和之间的区别是什么?和& amp; amp;在HTML5中? [英] Whats the difference between & and & in HTML5?

查看:96
本文介绍了和之间的区别是什么?和& amp; amp;在HTML5中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

& & amp;


之间有什么区别
$ p

< a href = mailto:EMAIL?subject = BLABLABLA& body = http:// URL,SHORT DESCRIPTION>< / a> 
< a href =mailto:EMAIL?subject = BLABLABLA& amp; body = http:// URL,SHORT DESCRIPTION>< / a>


解决方案

& amp; & 的html特殊字符,它对于html特殊字符具有特殊的含义。事实上, href =&的作品是大多数浏览器提供的便利,这些浏览器足以处理无效的HTML,但从技术上讲它是不正确的。您希望使用& amp; ,因为实体会在HTML代码中转换为&



考虑如果您使用而不是& 。会结束 href 值并使HTML不正确,对吗?您想使用& quot; p>

请参阅: http://www.w3.org/html/wg/drafts/html/master/single-page.html#syntax-errors 涉及脆弱语法结构的错误 - 事实上它指出使用& 是没有问题的,如果没有命名字符引用,但是有很多这样的引用;理想情况下,您会自动转义属性输入。


What is the difference between & and &amp;?

Like in the code bellow, are both working in the same way?

<a href="mailto:EMAIL?subject=BLABLABLA&body=http://URL, SHORT DESCRIPTION"></a>
<a href="mailto:EMAIL?subject=BLABLABLA&amp;body=http://URL, SHORT DESCRIPTION"></a>

解决方案

&amp; is the html special character for &, which has a special meaning as the sigial for html special characters. The fact that href="&" works is a convenience granted by most browsers who are nice enough to properly deal with invalid HTML, but it is technically incorrect. You want to use &amp; because the entity will be converted into & in the HTML code.

Consider if you used " instead of &. That would end the href value and make the HTML incorrect, right? You want to use &quot;.

See: http://www.w3.org/html/wg/drafts/html/master/single-page.html#syntax-errors "Errors involving fragile syntax constructs" -- in fact it points out that using & is okay if it's not followed by a named character reference, but there are many of those; ideally you would be escaping attribute input more or less automatically.

这篇关于和之间的区别是什么?和&amp; amp; amp;在HTML5中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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