What is your preferred format for html content?
Why do you choose one over the other?
What is your preferred format for html content?
Why do you choose one over the other?
I use XHTML 1.0 Strict, just because I immediately get notified on any coding errors. Additionally, I can use XML namespaces for SVG or other stuff, although I'm currently converting SVG images to png before displaying them.
Although using the XML prologue puts IE6 into Quirks mode, I'm lucky insofar as that my web clients are standard-compatible. For my personal (publicly available) pages, I'm using XHTML with prologue and doctype. If you are using a broken browser, my page may not be rendered correctly. So what? (Plus, most of it is plain text anyway atm). The only concession is Content-Type text/html
for older browsers and not totally breaking old IEs. But if you application/xhtml+xml
is in your Accept
header, you may get it.
If you want to support IE, you're stuck with HTML4.01 or html-compatible XHTML1.0, preferably in the strict variant. If not, choose whichever dialect you like best.
I myself mostly stick with HTML because XHTML is only needed when inlining data from other XML-dialects or when customizing doctypes, both of which will break compatibility with HTML and tagsoup-parsers.
In my opinion the only valid reason for choosing html-compatible XHTML1.0 over HTML4.01 is tool support: E.g. XHTML allows for better validators because of stricter syntax requirements and can be auto-generated via XSLT.
HTML-compatible (Appendix C) XHTML 1.0 Strict, served as text/html.
No, it doesn't get you anything on the browser in comparison to HTML 4.01. But I'm not doing it for the browser. It lets me manage my production systems at the server-side using plain XML tools, and anyone who needs to scrape my pages can do it with an XML parser instead of having to worry about the difficulties of parsing likely-malformed HTML.
The rules of XML may be stricter than HTML, but they're also simpler. Apart from the / in empty element syntax, XHTML is basically the same thing you'd be writing if you were doing HTML4 properly. You always quote your attributes like this, you always open and close your elements consistently, and so on.
XHTML is not very different from the HTML 4.01 standard.
The Most Important Differences:
HTML does not force these things but most browsers are quickly starting to expect it. Despite IE8 dropping it's Trident engine it looks as though they will still not support XHtml SO Strict is probably going to be your best option.
UPDATE:
Web Standard committee have opted against XHTML 2 and for HTML 5.
I use HTML (4.01 Strict or 5). This article explains the reasons why very well: http://www.webdevout.net/articles/beware-of-xhtml
Basically, with the state of browsers at the moment, XHTML as true XHTML isn't relaistic, and XHTML served as HTML gets treated as HTML, so you may as well use that.
Also, you don't have to use HTML 4.01, the HTML 5 doctype is now a viable option:
What's nice about this new DOCTYPE, especially, is that all current browsers (IE, FF, Opera, Safari) will look at it and switch the content into standards mode - even though they don't implement HTML5. This means that you could start writing your web pages using HTML5 today and have them last for a very, very, long time.
I use XHTML 1.0 STRICT for better cross-browser compatibility. (i.e. less IE/browser-specific hacks to use).
We keep our ... stick to: HTML 4.01 (and in future maybe HTML 5) because:
In XHTML you can't not use the useful and fast* JS function document.write cite: http://www.w3.org/MarkUp/2004/xhtml-faq#docwrite
We would get sick and tired to waste our time adding useless CDATA in code everytime we want to add inline scripts or styles containing reserved chars.
We get things done faster, we don't get frustrated, and our customers are still happy. But this is our personal opinion.
*still faster compared to waiting for document.onload event (or other ways to detect whne page is loaded, i.e. jQuery way).