gpt4 book ai didi

xhtml - 为什么是
而不是

转载 作者:行者123 更新时间:2023-12-03 12:00:15 25 4
gpt4 key购买 nike

这是你读过一次的那些东西之一,说“啊哈!”然后忘记。正是我的情况。

为什么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/>

所以最后的空格是可选的。

最佳答案

如果我没记错的话,这仅仅是因为一些较旧的浏览器在斜线前没有空格的自关闭标签存在问题。我怀疑现在这是一个问题,但是很多开发人员(包括我自己)都养成了包含空间的习惯。

编辑:啊,我们在这里:

http://www.w3.org/TR/xhtml1/#guidelines

Include a space before the trailing / and > of empty elements, e.g. <br />, <hr /> and <img src="karen.jpg" alt="Karen" />. Also, use the minimized tag syntax for empty elements, e.g. <br />, as the alternative syntax <br></br> allowed by XML gives uncertain results in many existing user agents.

关于xhtml - 为什么是 <br/> 而不是 <be/>?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1659208/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com