Html   和有什么不一样?和  ?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7511214/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 10:43:26  来源:igfitidea点击:

What is the difference between   and  ?

htmlxmlxsltspacehtml-entities

提问by Sambhaji

I have written one XSLT to transform xml to html. If input xml node contains only space then it inserts the space using following code.

我已经编写了一个 XSLT 来将 xml 转换为 html。如果输入 xml 节点仅包含空格,则它使用以下代码插入空格。

<xsl:text>&#xa0;</xsl:text>

There is another numeric character which also does same thing as shown below.

还有另一个数字字符也做同样的事情,如下所示。

<xsl:text>&#160;</xsl:text>

Is there any difference between these characters? Are there any examples where one of these will work and other will not?

这些字符之间有什么区别吗?是否有任何示例可以证明其中一个有效而其他无效?

Which one is recommended to add space?

推荐哪一个加空间?

Thanks,
Sambhaji

谢谢,
桑巴吉

回答by kapa

&#160;is a non-breaking space(&nbsp;).

&#160;是一个不间断空格( &nbsp;)。

&#xa0;is just the same, but in hexadecimal(in HTML entities, the xcharacter shows that a hexadecimal numberis coming). There is basically no difference, A0and 160are the same numbers in a different base.

&#xa0;一样的,但是是十六进制的(在HTML 实体中x字符表示一个十六进制数即将到来)。目前基本上没有区别,A0并且160在不同的基地相同的数字。

You should decide whether you really need a non-breaking space, or a simple space would suffice.

您应该决定是否真的需要一个不间断的空间,或者一个简单的空间就足够了。

回答by Xavi López

It's the same. It's a numeric character reference. A0is the same number as 160. The first is in base 16 (hexadecimal) and the second is in base 10 (decimal, everyday base).

一样的。这是一个数字字符参考A0是相同的数字160。第一个是基数 16(十六进制),第二个基数是 10(十进制,日常基数)。