The difference is that XHTML is based on XML while HTML is based on SGML.
Browsers use the SGML parser for content sent with the content type text/html
and the XML parser for application/xhtml+xml
.
When using the SGML parser, browsers will continue the parsing even when they encounter a syntax error in the file. This is why so many people think they are doing XHTML when they are sending XML-looking files to the browser. This is actually a mistake since this will trigger many parsing errors in the browser and slow the rendering process.
When using the XML parser, browser will stop the parsing when a syntax error is encountered and display an XML error. This is of course only true for browsers that have an XML parser for HTML content, which is not true for Internet Explorer that will only download the file and not display it.
What should you do then?
You should use XHTML if you need the syntax checking and the strict structure that XML impose. You should keep in mind that you must be sending your XHTML content to Internet Explorer with the wrong content type with all the issues implied. You should also keep in mind that your document will break whenever an unvalid content is in the file, so you must take great care to sanitize any user input.
You should use HTML for anything else. HTML just works and is a greatly supported standard today. Even the next standard HTML 5 defines an SGML-based syntax so this will last.
Keep in mind that whatever the format you choose, validating your output is always a good idea to detect syntax error.