tags:

views:

204

answers:

2

I keep being confused about the two. Can someone sum up the key difference(s) and maybe a typical use case very briefly?

Is XHTML just more "strict" / clean / XML-y?

If XHTML is just the "more correct" version of HTML, why should I ever use HTML at all?

+5  A: 

XHTML 1.0 is HTML 4.01 reimplemented using XML instead of SGML. This lets you process it with XML tools (but you need to be careful with the output if you want to support IE) and mix in other XML namespaces such as SVG or MathML (unless you want to support IE). Writing XHTML that is HTML compatible is a fair amount of effort and most people who try it screw it up so I suggest sticking to HTML.

David Dorward
XML is also subset of SGML (http://en.wikipedia.org/wiki/Standard_Generalized_Markup_Language#Derivatives)
Simon P Stevens
after HTML5 announce, XHTML is a dead branch of HTML?
dfa
So basically, XHTML is "more correct" XML-wise, but browsers (IE, at least) don't get it?
Hanno Fietz
It has things like namespaces grafted on. As far as I know, those are not available in SGML.
David Dorward
@dfa It was lack of support for XHTML from Microsoft, and lack of interest from browser vendors in XHTML 2 that killed it, not HTML5. HTML5 was a reaction to that, not the cause.
David Dorward
XHTML is "more correct" XML-wise in the sense that my Renault Cleo is more correct car-wise than the things that EasyJet fly about the world. HTML isn't XML. That isn't necessarily a bad thing.
David Dorward
You can use namespace-like syntax in SGML, but as far as I know it means nothing special to the parser. XML is a subset of SGML much as SGML is a subset of plain text.
Steve Jessop
(Actually that comparison isn't right, since SGML has processing features which XML doesn't use, whereas plain text has no processing features at all. But in terms of XML's processing features, they don't contradict SGML but they don't mean anything to it either. You can't in general write a DTD to match a given XML schema, or vice-versa.)
Steve Jessop
@dfa: XHTML is not a dead branch of HTML. The HTML 5 spec includes 2 variants of the language, a "classic" HTML variant and an XHTML variant. Both are fully supported under the HTML 5 spec. See http://en.wikipedia.org/wiki/HTML_5
Simon P Stevens
While it might be in the spec, without support from the browser that holds ~60% of the market, it might as well be dead.
David Dorward
A: 

XHTML is more or less HTML 4.x reimplemented in XML (instead of based on SGML directly) which results in some additional features like namespace support that make it easier to extend for problem specific markup while keeping it valid.

The problem is, that to this point as far as I know no browser actually interprets XHTML as XML completely so it's mostly a bonus for developers who want to operate on the generated markup (since it's XML and can therefor be parsed more easily).

So to keep it simple: XHTML is more strict.

Horst Gutmann
Opera, Safari, Chrome, Firefox, Konqueror and every other major browser except Internet Explorer interpret XHTML as XML if it is served with the correct content-type.
David Dorward
XHTML is not more strict. It throws away rules in HTML (such as "A table must have a tbody") because it can't handle implicit elements and the working group didn't want to make people have to start writing them explicitly.
David Dorward
Ah nice, didn't know that XML support was already fully integrated into other browsers. I always thought it was only limited.
Horst Gutmann