Self-closing tags don't exist in HTML. The /
is always ignored, that is, <foo/>
and <foo>
are equivalent. For elements such as br
, that's fine, because you want <br>
. However, <script src="..." />
means the same as <script src="...">
, which is a problem (as noted in other answers). <head/>
is less of a problem, because the </head>
end tag is optional anyway.
In XML, on the other hand, self-closing tags do what you want. However, you probably aren't using XML, even if you've got an XHTML doctype. Unless you send your documents with a text/xml
, application/xml
or application/xhtml+xml
MIME type (or any other XML MIME type), particularly if you send them as text/html
, they will not be treated as XML.