This is a complex question. I would say there is no concrete reason why you should use one over the other. The best thing is to take as much information about them as possible, form your own understanding and opinions and make your decision based on that.
Doctype Declarations
There is a fair bit of confusion surrounding this. I will attempt to summarise.
- HTML (4 and 5) should always have the appropriate doctype.
- XHTML ought to have a doctype, although it isn't strictly required if you are serving your pages with an XHTML content type (
application/xhtml+xml
) - be aware IE does not support this though!
- XHTML served with an HTML content type (
text/html
) does need the doctype to be present
- This list of doctypes may be of help
HTML 4, HTML 5, XHTML 1, XHTML 1.1...?
HTML 4 is the latest version of the HTML standard. XHTML 1 is a reformulation of this standard in XML, and became the more preferred one. XHTML 1.1 is a slightly updated standard which is best avoided due to the requirement for serving with the XHTML content type (as previously mentioned, well-used browsers will choke on this and your site will be useless). HTML 5 is not yet a standard but it is definitely heading that way. In addition, it is designed to be handled in a sensible way by older browsers not yet supporting it. It should just work, albeit in a diminished form if you use many of the new features.
If it were my decision, I'd seriously consider using HTML 5. It is the latest standard and nobody says you have to use all the new bits. But you are saving yourself work in the future if you decide to move towards using them then - you won't have to convert everything you have (doctypes etc). It's also quite permissive (by design).
If you decide against HTML5, there is nothing wrong with using either HTML 4.01 or XHTML 1. They are essentially slight variations on the same standard, and both are well established in terms of browser support.
If you really feel hardcore, check out the actual specs. Tough reading, but there's a lot of information there.
Declarations in the XHTML (added to answer the new question posed in the question)
<?xml version="1.0" encoding="UTF-8"?>
This is the XML declaration. It states that this is an XML file, encoded using UTF-8. This ought to be present when serving XHTML files with the application/xhtml+xml
content-type. If you are serving it as HTML (text/html
), it's probably best to avoid this. Certainly some versions of IE (can't remember which) will revert to quirks mode upon seeing this instead of a doctype at the beginning
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
This is the doctype. See above.
<html xmlns="http://www.w3.org/1999/xhtml">
This is the opening tag for the html
element (the root element of the document). The xmlns
attribute is specifying the namespace. This attribute (with this value) is required in an XHTML document, as noted in the specification.