David Dorward said:
It isn't optional. If you are writing regular HTML then you should not do
this at all. The closing slash means something somewhat different in HTML.
Actually it is the '>' character that means something completely
different in XHTML in this context. The 'closing' slash and the
'greater than' character have *nothing* to do with the EndTAGOpen
delimiter '</' and the TagClose delimiter '>' respectively.
In HTML, there is only one NullEndTag delimiter (the solidus) that would
appear as a matching pair if the content model of the element type is
*not* empty:
<foo/some foo text/
or simply
<foo//
if there were no content at all.
XML, however, uses the possibility introduced by Annex K of ISO8879 to
specify a *different character* as a *start* delimiter of the NET
shorthand feature, id est NetEnablingStartTagClose.
And in XML, they sadistically mapped the good old NET to '>' and NESTC
to the good old solidus ("it's a tag, Joe").
So, the ugly, asymmetrical, sexually frustrated <foo// larva can
transform into the beautiful <foo/> butterfly (if the element instance
does either not have any content or the element type's content model is
EMPTY) and live happily ever after.
It's a damned miracle (especially if you read all the helpful
explanations at jolly good low-contrast microfont e-zines about stuff
like this).