这是那种你看一次就会恍然大悟,但之后又会忘记的事情。我也是一样。
为什么在xhtml中,换行标签优先写成 <br />
带有空格,而不是可以接受的格式<br/>
?我记得原因很有趣,而且你可以想象通过谷歌并不容易找到答案。
毫无疑问,这不是xml格式问题。来自W3C的说明:
[44] EmptyElemTag ::= '<' Name (S Attribute)* S? '/>'
Empty-element tags may be used for any element which has no content, whether
or not it is declared using the keyword EMPTY. For interoperability, the
empty-element tag should be used, and should only be used, for elements which
are declared EMPTY.
Examples of empty elements:
<IMG align="left" src="http://www.w3.org/Icons/WWW/w3c_home" />
<br></br>
<br/>
所以末尾的空格是可选的。