HTML 5 versus XHTML 1.0 Transitional?

It seems that HTML 5 is going to be supported (partially) by Firefox 3.1 and other browsers. It is adding support for video and audio as tags, but these are new tags that XHTML 1.0 Transitional does not recognize. What is the behavior supposed to be if I use a new HTML 5 tag in a future version of Firefox but use the DTD for XHTML? And what if I mix HTML 5 markup with XHTML 1.0 Trans?

This is getting confusing. Why didn't they just add these tags to XHTML? How do we support both XHTML and HTML 5?

Video on HTML 5: http://www.youtube.com/watch?v=xIxDJof7xxQ


Well, generally speaking HTML is SGML and XHTML is expressed in XML. Because of that, creating XHTML is connected with more restrictions (in the form of markup) than HTML is. (SGML-based versus XML-based HTML)

As mentioned on Wikipedia, HTML 5 will also have a XHTML variant (XHTML 5).

Rule of thumb: You should always use valid markup. That also means that you should not use the mentioned <video> or <audio> tags in XHTML 1.0 Transitional, as those are not an element of that specification. If you really need to use those tags (which I highly doubt), then you should make sure that you use the HTML 5/XHTML 5 DTD in order to specify that your document is in that DOCTYPE.

Using HTML 5 or XHTML 5 in the given state of the implementation (AFAIK, the standard is not even settled, yet, correct?) could be counter-productive, as almost all users may not see the website rendered correclty anyways.

Edit 2013: Because of the recent downvotes and since this accepted answer cannot be deleted (by me), I would like to add that the support and standardization process of HTML5 is nowadays totally different to what it was when I wrote this answer five years ago. Since most major browsers support most parts of the HTML5 draft and because a lot of stuff can be fixed with polyfills in older browsers, I mainly use HTML5 now.


HTML5 is so much easier to write than XHTML 1.0.

  • You don't have to manually declare the "http://www.w3.org/1999/xhtml" namespace.

  • You don't have to add type attributes to script and style elements (they default to text/javascript and text/css).

  • You don't have to use a long doctype where the browser just ignores most of it. You must use <!DOCTYPE html>, which is easy to remember.

  • You don't have a choice to include or not include a dtd uri in the doctype and you don't have a choice between transitional and strict. You just have a strict doctype that invokes full standards mode. That way, you don't have to worry about accidentally being in Almost standards mode or Quirks mode.

  • The charset declaration is much simpler. It's just <meta charset="utf-8">.

  • If you find it confusing to write void elements as <name>, you can use <name/>, if you want.

  • HTML5 has a really good validator at http://validator.nu/. The validator isn't bound by a crappy DTD that can't express all the rules.

  • You don't have to add //<![CDATA etc. in inline scripts or stylesheets (in certain situations) to validate.

  • You can use embed if needed.

  • Just syntax-wise, when you use HTML5, you end up with cleaner, easier to read markup that always invokes standards mode. When you use XHTML 1.0 (served as text/html), you're specifying a bunch of crud (in order to validate against a crappy dtd) that the browser will do automatically.


    Myths and misconceptions abound in this thread.

  • XHTML 1.0 is older than HTML 5. It cannot use any new vocabulary. Indeed, its main selling point was that it uses exactly the same vocabulary as HTML 4.01.

  • There will be no XHTML 1.2 - most probably. And it is not needed. XHTML 5 is the XML serialization of HTML 5. Identical vocabulary, different parsing rules.

  • HTML has never been treated as true SGML in browsers. No browser has ever implemented an SGML-compliant parser. HTML 5 will make this fact into a rule and the HTML serialization will follow todays de facto standard. One could perhaps say that it is "SGML-ish".

  • As it has been stated, the DTD serves exactly one purpose IN BROWSERS, and that is to distinguish between standards compliance mode and quirks mode. Thus it affects only styling and scripting. If you are using frames on a page with astrict doctype, they will render just fine. As will <embed> and even <marquee> - even though the latter is an abomination and the former not in any current standard. It is part of HTML 5, though.

  • Video and audio can be used regardless of serialization, XML or HTML. they are part of both HTML 5 and XHTML 5. Once the parsing stage is over a browser will have constructed an internal DOM of the document. That DOM will be for all practical purposes the same regardless of serialization. And yes, XHTML sent with text/html is still normal html, regardless of doctype.

  • 链接地址: http://www.djcxy.com/p/18978.html

    上一篇: HTML:包含或排除可选的结束标记?

    下一篇: HTML 5与XHTML 1.0 Transitional?