I’ve always had this nagging question. Is
<a name="target"/> legal XHTML? I mean, it seems like kind of waste to have to do
<a name="target"></a> all the time. Same thing with
<script src="file.js"></script>, but I wasn’t sure if I could just arbitrarily use the empty element shorthand.
Turns out I can’t. There’s limited list of tags in the XHTML 1.0 DTD that can use the empty element shorthand:
A quick search for “empty” on the XHTML 1.0 DTD returns the following list of tags that can legally use the empty element shorthand:
<script/> are not on that list.
This post first appeared on From the Belly of the Beasts, a weblog from some of the people who build O’Reilly websites.