Which one is better and why for a new project? I'm assuming all will be strict, as I see no reason to go transitional for a new project.
4 Answers
HTML 4.01 vs. XHTML 1.0
The problem with both of these is that they have been effectively rendered obsolete by HTML5.
In fact, you're really asking the wrong question. HTML4, XHTML and HTML5 are basically the same language, but with certain features missing from one to the other.
The really important thing (and probably the reason why you may feel like you have to choose) is that it is important to specify a doctype, in order to prevent older browsers dropping into quirks mode. At the point where you find you have to specify a doctype, you also find yourself presented with a choice of which one to use, and the syntax makes it look like you have to get it absolutely perfect or it'll all stop working.
But you don't need to worry about that. The following doctype is sufficient to make all current browsers (including IE6) run in standards mode:
<!DOCTYPE html>
Simple, eh? No need to worry about HTML4 vs XHTML at all.
The thing is, the above doctype also happens to be the doctype for HTML5. It was chosen deliberately because it works in existing browsers.
If you need to support older browsers, you don't have to use HTML5's flashy new features, but using this doctype means that you will be ready to use them when the time comes. And if you do feel like dipping your toe in the water, a lot of the new features will degrade gracefully in older browsers, so you can use them; they may not work in IE6, but they won't break the browser either.
I hope that helps.
-
2They have not been rendered obsolete by HTML 5 — it is still a draft, it builds on top of them, and it still gives you the choice between targeting XML parsers and tag soup parsers. – Quentin Feb 12 '11 at 19:02
-
The Doctype (until HTML 5) also provided a DTD to validate against. You need to use a dedicated HTML 5 QA tool (which can't be all that mature and is still tracking a moving target) rather then a generic SGML or XML validator. – Quentin Feb 12 '11 at 19:03
-
I still don't get this big put to use the HTML 5 Doctype so that you can use HTML 5 features in the future. What sort of system makes it a big job to change the Doctype in a template? – Quentin Feb 12 '11 at 19:05
-
1The fact is that HTML5 is the future. Work on XHTML2 has effectively been abandoned, and all current work is heading in the direction of HTML5 and related technologies. If you want to keep up to date over the next few years, HTML5 is the only way to go. – Spudley Feb 12 '11 at 19:14
-
1@David Dorward - Frankly, I'd sooner not specify a doctype at all. I'm forced to due to the quirks mode issue, but there's no other reason. If I want to validate a document, I'm quite capable of telling the validator what type of document it is. Having the doctype in the code is arbitrary, and a waste of bandwidth (the browser doesn't need to know it; it doesn't care, and will make an effort to render the page even if you specify the wrong doctype). – Spudley Feb 12 '11 at 19:20
-
HTML 5 probably is the future, but the present is not. If features of HTML 5 aren't robust or don't provide a benefit today, then they usually shouldn't be used today. If they do provide a benefit, then they should be used with caution as the spec is still in flux. Either way, the decision to use HTML 5 should be based on it offering something useful, not because of being all futury. – Quentin Feb 12 '11 at 19:37
-
@David Dorward - Fine, don't use the features (I'm not using them, as I need to support IE7/8). You can still use the short doctype, which I still hold is a sensible option, and removes the need to debate over which (x)HTML to use. – Spudley Feb 12 '11 at 19:45
-
1@Spudley - The one thing HTML5 does not do is resolve the question of whether to use an HTML serialization or an XHTML one, (or indeed a polyglot one) since both serializations are covered by the HTML5 spec. – Alohci Feb 12 '11 at 20:48
If it's for a new project, start reading up on HTML5
. It has the best of both, without the tag soup
and doctype
madness of XHTML
.

- 6,796
- 4
- 40
- 50

- 3,187
- 1
- 20
- 17
-
By that, I'm not suggesting you use cutting edge html5 features, but simply use the html5 doctype and produce future proof html code for all browsers. – leebriggs Feb 12 '11 at 18:40
-
2The best of both? XHTML has two benefits over HTML. The ability to mix namespaces (which HTML 5 doesn't have) and *reducing* tag soup by enforcing well formedness: by removing optional end tags and eliminating boolean attribute values … which HTML 5 puts back in. HTML 5 also introduces doctype madness by removing all the useful information (the location of a machine parsable description of the language for performing syntax checking against). – Quentin Feb 12 '11 at 18:43
If you are using an XML toolchain, and it can handle HTML compatibility (which is needed for IE 6-8) then you might consider going with XHTML, otherwise go with HTML.
If any of the features added in HTML 5 are going to be useful to you, and browser support for those features is mature enough then go with (X)HTML 5, otherwise go with HTML 4.01 / XHTML 1.0 as they have more mature QA tools.

- 914,110
- 126
- 1,211
- 1,335
XHTML (or HTML 5, for that matter).
We're talking about +10 years in web evolution. If you're the web developer or designer, go Strict and validate your code - it will assure that your site (given valid CSS) will display correctly in most operating systems and web browsers. It will be easier to maintain. It will make you a better webdev because you'll know and understand semantics. It will be easier to migrate to HTML 5 in the future too.

- 3,969
- 3
- 23
- 30
-
'XHTML (or HTML 5, for that matter)' - just this sentence casts a lot of doubt on your answer – Mchl Feb 12 '11 at 18:29
-
@Mchl Why is that? Even if it's still a draft, it could be used, and it's being used. It's an option that can be taken into account. – AeroCross Feb 12 '11 at 18:32
-
HTML 4 is far from dead, it is so not dead that almost everybody trying to write XHTML is serving it as text/html and depending on the browser engines designed to parse HTML 4 to cope with it. – Quentin Feb 12 '11 at 18:40
-
Someone should break the news to stackoverflow, who use the html4 doctype. – leebriggs Feb 12 '11 at 18:45
-
@David I'm an advocate of XHTML, and I've always seen XHTML as an improvement to HTML 4.01 semantics. I can't see any real reason not to use XHTML over HTML 4. The case is different for HTML 5 though - as @leeeb said, it's not necessary to use the cutting-edge features of the spec. I feel XHTML gives you a cleaner, more robust markup. – AeroCross Feb 12 '11 at 18:50
-
1Main reason is what David says. Also XHTML1 is not, contrary to popular belief, a successor to HTML4, and HTML5 is not a successor to XHTML1. On top of that IE can't handle XHTML if it's send using correct mime. – Mchl Feb 12 '11 at 18:50
-
@AeroCross: No doubt, XHTML, being XML has a cleaner markup than HTML. I would love to see wider adoption of XHTML, but as it is now, if it's used, it's usually used incorrectly. Please see here for some more details: http://en.wikipedia.org/wiki/XHTML#Adoption – Mchl Feb 12 '11 at 18:52
-
1XHTML doesn't give you more robust markup (since the parsing rules for HTML are clearly defined). The cleanliness of it is also subject to debate, the removal of optional tags and boolean attributes means documents are cluttered up with extra markup that could previously be implied. – Quentin Feb 12 '11 at 18:55
-
It's my point of view - of course it has clearly defined parsing rules, but it's like the choice of a scripting language: some use Python, some PHP, but the result for the user (the "proyect") is the same, and it's delivered. It could be taken into consideration what does the webdev wants - in my case, I don't like "implied" markup, for example. – AeroCross Feb 12 '11 at 19:11
-