Is there a semantic difference between <tag /> and <tag></tag> in XML? Is there a semantic difference between <tag /> and <tag></tag> in XML? xml xml

Is there a semantic difference between <tag /> and <tag></tag> in XML?


No

Start-tag/End-tag (<tag></tag>) and Empty-element tag (<tag/>) forms are semantically equivalent. No conforming XML parser will treat them differently.


Reference: Extensible Markup Language (XML) 1.0 (Fifth Edition)


Historical note: There is also an antiquated SGML compatibility reference, which I include for completeness:

For interoperability, the empty-element tag should be used, and should only be used, for elements which are declared EMPTY.

  • 1.2 Terminology

    for interoperability

    [Definition: 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.]


Related Q/A: