Space Before Closing Slash?

后端 未结 8 1828
说谎
说谎 2020-11-27 15:29

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


<
8条回答
  •  孤独总比滥情好
    2020-11-27 16:17

    Supporting bobince's answer with screenshot of Netscape 4.80 showing documents

    data:text/html,spacefoo
    bar

    (top left, linebreak rendered) and

    data:text/html,no spacefoo
    bar

    (bottom left, linebreak ignored).


    Posting as answer to show the picture

    Tangentially related: in fact I had a lengthy answer identifying the cause of such misbehaviour of ancient browsers (and resulting recommendation to include space) in misunderstood SGML specs, namely SGML Null End Tag (NET) (where 1 equals 123 so 12 would actually mean 1>2), but not only I was unable to find good proof and concrete version of standard, I wasn't even able to grasp proper standard-complying behaviour. So few raw links for reference:

    • w3c validator notice mentioning problematic closing slash and pointing to
    • Empty elements in SGML, HTML, XML, and XHTML @ www.cs.tut.fi/~jkorpela/
    • Beware of XHTML: Null End Tags (NET) stating, that

      However, there are still some smaller user agents that properly support Null End Tags. One of the more well-known user agents that support it is the W3C validator.

    (Unable to reproduce there now, but supports Lee Kowalkowski's statement about multiple browsers affected by this.)

    • XML W3C Working Draft 07-Aug-97 - latest specs draft that includes reference of Null End Tag in DTD snippet: NET "/>"

提交回复
热议问题