Hanno Fietz
Hanno Fietz

Reputation: 31360

In a nutshell, what's the difference between XHTML and HTML?

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?

Upvotes: 4

Views: 589

Answers (3)

Paul D. Waite
Paul D. Waite

Reputation: 98786

In a word: syntax.

XHTML is HTML that conforms to the XML syntax rules. (Unless I’m missing something, XML itself is just a set of syntax rules.)

If I understand correctly, HTML looks a bit like SGML, and looks a bit like XML, but effectively has its own somewhat idiosyncratic syntax rules that are reasonably effectively implemented by the major web browsers, and are now codified in the HTML5 spec (whereas before, they hadn’t been codified outside of the behaviour of the web browsers themselves).

Upvotes: 1

Horst Gutmann
Horst Gutmann

Reputation: 11308

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.

Upvotes: -1

Quentin
Quentin

Reputation: 943098

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.

Upvotes: 7

Related Questions