What are all the valid self-closing elements (e.g.
) in XHTML (as implemented by the major browsers)?
I know that XHTML technically allows any element to
I'm not going to try to overelaborate on this, especially since the majority of pages that I write are either generated or the tag does have content. The only two that have ever given me trouble when making them self-closing are:
For this, I have simply resorted to always giving it a separate closing tag, since once it's up there in the it doesn't really make your code any messier to work with anyway.
This is the big one that I very recently ran into problems with. For years I had always used self-closing tags when the script is coming from an external source. But I very recently started recieving JavaScript error messages about a null form. After several days of research, I found that the problem was (supposedly) that the browser was never getting to the
tag because it didn't realize this was the end of the
tag. So when I made it into separate
tags, everything worked. Why different in different pages I made on the same browser, I don't know, but it was a big relief to find the solution!