4 comments

[ 2.6 ms ] story [ 22.0 ms ] thread
Should an XHTML document start with a typical <?xml version="1.0" encoding="UTF-8" ?> header?
Depends if you target the browsers HTML parser or XHTML parser.

Include it if you target the XHTML parser. (Note that if you target the XHTML parser, IE will not show the document at all.) Leave it out if you target the HTML parser. (But if you target the HTML parser, you might as well use HTML.)

Theoretically you could target both HTML and XHTML parsers with the same document, e.g. by using content negotiation. Since this is a lot of hassle and has no real benefit, not a lot of people does this. But in this theroretical case the correct is to leave the prolog out, since it is optional in XML and illegal in HTML.

My issue with this draconian failure stuff is that (in Firefox at least) view source yields no content when it finds an error in page & obviously the line number it gives for the error can be very far removed from the underlying code.
Most people prefer XHTML syntax, that's why they use XHTML doctype in HTML documents. There's nothing wrong with it.