Why Does The Empty-Element Tag Exist?

The existence of the empty-element tag is sort of an accident of history. In SGML, there is no difference at all, so you can't tell whether <IMG src='madonna.jpg'> is a start-tag or an empty element without looking at the DTD. In XML, this is unacceptable, since you have to be able to parse documents received over the network without first fetching a DTD or any other external help. So we invented the empty-element tag syntax as a way to make such elements obvious and parsing easy.

Later on in the process, we realized that there was no difference between the two forms of empty elements, and thus no real strong need for the empty-element tag; in fact, it's just a shorthand, space-saving abbreviation. Had we been keeping strictly to our design principles, we would have tossed it out of the language; but by that time we'd had it for a few months, and people really seemed to like it.

Back-link to spec

Copyright © 1998, Tim Bray. All rights reserved.