39

What is the exact difference between HTML and XHTML?

I have seen related posts here, but I am not getting it exactly.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131

4 Answers4

54

XHTML is not so much different from HTML 4.01 standard. The major differences are:

  • XHTML elements must be properly nested.
  • XHTML elements must always be closed.
  • XHTML elements must be in lowercase.
  • XHTML documents must have one root element.

Basically, XHTML is HTML (all the html tags are found in XHTML) that follows the rules of XML (because it is a family of XML).

More references can be found on:

John
  • 1,210
  • 5
  • 23
  • 51
Buhake Sindi
  • 87,898
  • 29
  • 167
  • 228
  • 5
    Should make it a little more clear that they are that XHTML is the EXACT same thing as HTML albeit with XML rules enforced. – Jim Mitchener Nov 11 '10 at 10:38
  • 2
    @jcm, using the word **EXACT** has a different meaning. I agree they look exactly the same. :) – Buhake Sindi Nov 11 '10 at 10:47
  • 2
    XHTML is identical to HTML sans XML strictness. I just don't feel "XHTML is not so much different from HTML" conveys that. It's like you are hiding something and a novice will still feel they are not getting the whole picture. – Jim Mitchener Nov 11 '10 at 11:03
  • @jcm, Aah, I get what you mean...will try rephrasing it. – Buhake Sindi Nov 11 '10 at 11:10
12

XHTML is an application of XML, which is quite a strict angle-bracket language.

HTML is an application of SGML, which is a much less strict angle-bracket language.

(XML is also an application of SGML.)

At one time, people hoped that the solution to the mess of the late 90s web markup was to persuade everyone to write XHTML rather than HTML, perhaps in the hope that the enforced discipline would transform all those polo-necked frameless-spectacle wearing graphic designers into computer programmers. Alas, there was not actually much demonstrable benefit to all this exhausting prostration at the altar of the XHTML validator, so XHTML is now out of fashion and HTML is back in.

Will Dean
  • 39,055
  • 11
  • 90
  • 118
6

XHTML will be treated an application of XML only in case where MIME type application/xhtml+xml, application/xml, or text/xml are used. An XHTML document served with a MIME type of text/html must be parsed and interpreted as HTML, so the HTML rules apply in this case.

Check this link for more on difference between XHTML and HTML

ppant
  • 752
  • 9
  • 19
-2
  1. XHTML is case sensitive, different from HTML.
  2. XHTML's tags must be opened and closed different from HTML where a tag can be left as open.
  3. XHTML is not browser-dependent and can run on any browser platform, unlike HTML.
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131