(X)HTML中的保留字符是什么? [英] What Are The Reserved Characters In (X)HTML?

查看:104
本文介绍了(X)HTML中的保留字符是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,我搜索了它,并且出人意料地得到了令人困惑的答案。

$ b

一页说< > &安培; 是(X)HTML中唯一的保留字符。毫无疑问,这是合理的。


$ b

此页面显示 <&'是保留字符在(X)HTML中。有点令人困惑,但没关系,这也是有道理的。 然后这个页面,它表示< > &安培; (X)HTML中的所有保留字符,这是完全没有意义的(所有的字符都是空格) ,并且几乎增加了我的困惑。



有人知道,谁真的知道这些东西,澄清(X)HTML中的保留字符实际上是?



编辑:另外,如果包裹在<< ; pre> tag?或者它只是这三个 - <>& ??

解决方案

只有< & '(取决于您使用哪种引用样式

 < a href =#onclick =这里您可以使用安全>< / a> 
< a href =#onclick ='在这里您可以使用安全>< / a>


Yes, I've googled it, and surprisingly got confusing answers.

One page says that < > & " are the only reserved characters in (X)HTML. No doubt, this makes sense.

This page says < > & " ' are the reserved characters in (X)HTML. A little confusing, but okay, this makes sense too.

And then comes this page which says < > & " © ° £ and non-breaking space (&nbsp) are all reserved characters in (X)HTML. This makes no sense at all, and pretty much adds to my confusion.

Can someone knowledgeable, who actually do know this stuff, clarify which the reserved characters in (X)HTML actually are?

EDIT: Also, should all the reserved characters in code be escaped when wrapped in <pre> tag? or is it just these three -- < > & ??

解决方案

Only < and & need to be escaped. Inside attributes, " or ' (depending on which quote style you use for the attribute's value) needs to be escaped, too.

<a href="#" onclick="here you can use ' safely"></a>
<a href="#" onclick='here you can use " safely'></a>

这篇关于(X)HTML中的保留字符是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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