3 ms·
In XML, they are referred to as "empty-element tags" and are functionally equivalent to a start tag immediately followed by an end tag, such as <br></br> or <hr
by Archelaos 3y ago
In XML, they are referred to as "empty-element tags" and are functionally equivalent to a start tag immediately followed by an end tag, such as <br></br> or <hr></hr>. If a tag has no content, it can in principle also be written as an empty-element tag, for example: </p>. However, such use is not recommended: "For interoperability, the empty-element tag SHOULD be used, and SHOULD only be used, for elements which are declared EMPTY."[1] "For interoperability" is defined as: "Marks a sentence describing a non-binding recommendation included to increase the chances that XML documents can be processed by the existing installed base of SGML processors which predate the WebSGML Adaptations Annex to ISO 8879."[2a] "SHOULD" is explicitly[2b] used as defined in RFC 2119: "This word [...] mean that there may exist valid reasons in particular circumstances to ignore a particular item, but the full implications must be understood and carefully weighed before choosing a different course."[3]
[1] https://www.w3.org/TR/xml/#NT-EmptyElemTag https://www.w3.org/TR/xml/#NT-EmptyElemTag
[2a][2b] https://www.w3.org/TR/xml/#sec-terminology https://www.w3.org/TR/xml/#sec-terminology
[3] https://www.ietf.org/rfc/rfc2119.txt https://www.ietf.org/rfc/rfc2119.txt