关闭斜线之前的空间? [英] Space Before Closing Slash?

查看:100
本文介绍了关闭斜线之前的空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在XML和HTML标记中,我经常在关闭斜杠之前看到一个空格。 XHTML换行符可能是规范的例子:

 < br / 

而不是:

 < br /> 

这个空间似乎是多余的。实际上,我认为这是多余的。



写这个空间的原因是什么? b $ b

我读过这个空间解决了一些向后兼容性问题。哪些向后兼容性问题?这些问题是否仍然相关,还是为了IE3兼容性而添加额外的空间?是否存在一些规范与此确定的答案?



如果不向后兼容性,那么它是一个可读性问题吗?

  void it_goes_up_here(){

int no_you_fool_it_goes_down_there
{

我可以尊重不同的风格观点,所以我很乐意学习

解决方案

答案是人们希望遵守 XHTML1.0规范的附录C 。您只需将XHTML作为文本/ HTML 投放即可。大多数人都这样做,因为XHTML的真正MIME类型(应用程序/ html + xml)在Internet Explorer中不起作用。



当前浏览器不关心空间。浏览器非常容忍这些东西。



用于确保HTML解析器将尾部斜杠视为无法识别的属性所需的空间。


I've frequently seen a space preceding the closing slash in XML and HTML tags. The XHTML line break is probably the canonical example:

<br />

instead of:

<br/>

The space seems superfluous. In fact, I think that it is superfluous.

What is the reason for writing this space?

I've read that the space solves some "backwards compatibility issues." Which backwards compatibility issues? Are those issues still relevant, or are we still adding extra spaces for the sake of, say, IE3 compatibility? Does there exist some spec with the definitive answer on this?

If not backwards compatibility, then is it a readability issue? Similar to the Great Open Curly Brace debate?

void it_goes_up_here() {

int no_you_fool_it_goes_down_there()
{

I can certainly respect differing stylistic opinions, so I'll be happy to learn that writing the space is simply a matter of taste.

解决方案

The answer is people wish to adhere to Appendix C of the XHTML1.0 specification. Which you only need to do if you are serving XHTML as text/html. Which most people do, because XHTML's real MIME type (application/html+xml) does not work in Internet Explorer.

No current browser cares for the space. Browsers are very tolerant of these things.

The space used to be required to ensure HTML parsers treated the trailing slash as an unrecognised attribute.

这篇关于关闭斜线之前的空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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