XHTML explained

XHTML
Extension:.xhtml, .xht,
.xml, .html, .htm
Mime:application/xhtml+xml
Developer:WHATWG
Uniform Type:public.xhtml
Conforms To:public.xml
Owner:World Wide Web Consortium (W3C)
Genre:Markup language
Extended From:XML, HTML
Open:Yes
Standard:HTML LS

Extensible HyperText Markup Language (XHTML) is part of the family of XML markup languages which mirrors or extends versions of the widely used HyperText Markup Language (HTML), the language in which Web pages are formulated.

While HTML, prior to HTML5, was defined as an application of Standard Generalized Markup Language (SGML), a flexible markup language framework, XHTML is an application of XML, a more restrictive subset of SGML. XHTML documents are well-formed and may therefore be parsed using standard XML parsers, unlike HTML, which requires a lenient, HTML-specific parser.[1]

XHTML 1.0 became a World Wide Web Consortium (W3C) recommendation on 26 January 2000. XHTML 1.1 became a W3C recommendation on 31 May 2001. XHTML is now referred to as "the XML syntax for HTML"[2] [3] and being developed as an XML adaptation of the HTML living standard.[4] [5]

Overview

XHTML 1.0 was "a reformulation of the three HTML 4 document types as applications of XML 1.0".[6] The World Wide Web Consortium also simultaneously maintained the HTML 4.01 Recommendation. In the XHTML 1.0 Recommendation document, as published and revised in August 2002, the W3C commented that "The XHTML family is the next step in the evolution of the Internet. By migrating to XHTML today, content developers can enter the XML world with all of its attendant benefits, while remaining confident in their content's backward and future compatibility."[6]

However, in 2005, the Web Hypertext Application Technology Working Group (WHATWG) formed, independently of the W3C, to work on advancing ordinary HTML not based on XHTML. The WHATWG eventually began working on a standard that supported both XML and non-XML serializations, HTML5, in parallel to W3C standards such as XHTML 2.0. In 2007, the W3C's HTML working group voted to officially recognize HTML5 and work on it as the next generation HTML standard.[7] In 2009, the W3C allowed the XHTML 2.0 Working Group's charter to expire, acknowledging that HTML5 would be the sole next-generation HTML standard, including both XML and non-XML serializations. Of the two serializations, the W3C suggests that most authors use the HTML syntax, rather than the XHTML syntax.[8]

The W3C recommendations of both XHTML 1.0 and XHTML 1.1 were retired on 27 March 2018,[9] [10] along with HTML 4.0,[11] HTML 4.01,[12] and HTML5.[13]

Motivation

XHTML was developed to make HTML more extensible and increase interoperability with other data formats.[14] In addition, browsers were forgiving of errors in HTML, and most websites were displayed despite technical errors in the markup; XHTML introduced stricter error handling.[15] HTML 4 was ostensibly an application of Standard Generalized Markup Language (SGML); however the specification for SGML was complex, and neither web browsers nor the HTML 4 Recommendation were fully conformant to it.[16] The XML standard, approved in 1998, provided a simpler data format closer in simplicity to HTML 4.[17] By shifting to an XML format, it was hoped HTML would become compatible with common XML tools;[18] servers and proxies would be able to transform content, as necessary, for constrained devices such as mobile phones.[19] By using namespaces, XHTML documents could provide extensibility by including fragments from other XML-based languages such as Scalable Vector Graphics and MathML.[20] Finally, the renewed work would provide an opportunity to divide HTML into reusable components (XHTML Modularization) and clean up untidy parts of the language.[21]

Relationship to HTML

There are various differences between XHTML and HTML. The Document Object Model (DOM) is a tree structure that represents the page internally in applications, and XHTML and HTML are two different ways of representing that in markup. Both are less expressive than the DOM – for example, "--" may be placed in comments in the DOM, but cannot be represented in a comment in either XHTML or HTML – and generally, XHTML's XML syntax is more expressive than HTML (for example, arbitrary namespaces are not allowed in HTML). XHTML uses an XML syntax, while HTML uses a pseudo-SGML syntax (officially SGML for HTML 4 and under, but never in practice, and standardized away from SGML in HTML5). Because the expressible contents of the DOM syntax are slightly different, there are some changes in actual behavior between the two models. Syntax differences, however, can be overcome by implementing an alternate translational framework within the markup.

First, there are some differences in syntax:[22]

In addition to the syntactical differences, there are some behavioral differences, mostly arising from the underlying differences in serialization. For example:

Adoption

The similarities between HTML 4.01 and XHTML 1.0 led many websites and content management systems to adopt the initial W3C XHTML 1.0 Recommendation. To aid authors in the transition, the W3C provided guidance on how to publish XHTML 1.0 documents in an HTML-compatible manner, and serve them to browsers that were not designed for XHTML.[26] [27]

Such "HTML-compatible" content is sent using the HTML media type (text/html) rather than the official Internet media type for XHTML (application/xhtml+xml). When measuring the adoption of XHTML to that of regular HTML, therefore, it is important to distinguish whether it is media type usage or actual document contents that are being compared.[28] [29]

Most web browsers have mature support[30] for all of the possible XHTML media types.[31] The notable exception is Internet Explorer versions 8 and earlier by Microsoft; rather than rendering application/xhtml+xml content, a dialog box invites the user to save the content to disk instead. Both Internet Explorer 7 (released in 2006) and Internet Explorer 8 (released in March 2009) exhibit this behavior.[32] Microsoft developer Chris Wilson explained in 2005 that IE7's priorities were improved browser security and CSS support, and that proper XHTML support would be difficult to graft onto IE's compatibility-oriented HTML parser;[33] however, Microsoft added support for true XHTML in IE9.[34]

As long as support is not widespread, most web developers avoid using XHTML that is not HTML-compatible,[35] so advantages of XML such as namespaces, faster parsing, and smaller-footprint browsers do not benefit the user.[36] [37] [38]

Criticism

In the early 2000s, some Web developers began to question why Web authors ever made the leap into authoring in XHTML.[39] [40] [41] Others countered that the problems ascribed to the use of XHTML could mostly be attributed to two main sources: the production of invalid XHTML documents by some Web authors and the lack of support for XHTML built into Internet Explorer 6.[42] [43] They went on to describe the benefits of XML-based Web documents (i.e. XHTML) regarding searching, indexing, and parsing as well as future-proofing the Web itself.

In October 2006, HTML inventor and W3C chair Tim Berners-Lee, introducing a major W3C effort to develop a new HTML specification, posted in his blog that "[t]he attempt to get the world to switch to XML ... all at once didn't work. The large HTML-generating public did not move ... Some large communities did shift and are enjoying the fruits of well-formed systems ... The plan is to charter a completely new HTML group."[44] The current HTML5 working draft says "special attention has been given to defining clear conformance criteria for user agents in an effort to improve interoperability ... while at the same time updating the HTML specifications to address issues raised in the past few years." Ian Hickson, editor of the HTML5 specification criticizing the improper use of XHTML in 2002,[39] is a member of the group developing this specification and is listed as one of the co-editors of the current working draft.[45]

Simon Pieters researched the XML-compliance of mobile browsers[46] and concluded "the claim that XHTML would be needed for mobile devices is simply a myth".

Versions of XHTML

XHTML 1.0

Notes and References

  1. Web site: Graff . Eliot . Polyglot Markup: A robust profile of the HTML5 vocabulary . . 7 May 2014 . 17 October 2015 . 16 June 2022 . https://web.archive.org/web/20220616202318/https://dev.w3.org/html5/html-polyglot/html-polyglot.html . dead.
  2. Web site: Writing documents in the XML syntax. . live . https://web.archive.org/web/20230707043310/https://html.spec.whatwg.org/multipage/xhtml.html . 7 July 2023 . HTML Living Standard .
  3. Web site: The XML syntax. . live . https://web.archive.org/web/20230605155122/https://html.spec.whatwg.org/dev/xhtml.html . 5 June 2023 . HTML: The Living Standard .
  4. Web site: HTML vs. XHTML. whatwg.org.
  5. Web site: The WHATWG Blog. whatwg.org. 25 July 2010 .
  6. Web site: 2007-06-16. 2000-01-26. World Wide Web Consortium. XHTML 1.0 Specification, Section 1: What is XHTML?.
  7. Web site: results of HTML 5 text, editor, name questions. W3C .
  8. Web site: HTML5 Working Draft, Section 1.6: HTML vs XHTML. 2011-02-16. 2011-01-13. World Wide Web Consortium.
  9. Web site: XHTML™ 1.0 The Extensible HyperText Markup Language (Second Edition) Publication History. 27 March 2018 . World Wide Web Consortium.
  10. Web site: XHTML™ 1.1 - Module-based XHTML - Second Edition Publication History. 27 March 2018 . World Wide Web Consortium.
  11. Web site: HTML 4.0 Publication History. 27 March 2018 . World Wide Web Consortium.
  12. Web site: HTML 4.01 Publication History. 27 March 2018 . World Wide Web Consortium.
  13. Web site: HTML5 Publication History. 27 March 2018 . World Wide Web Consortium.
  14. Web site: 2007-06-16. 2000-01-26. World Wide Web Consortium. XHTML 1.0 Specification, Section 1.1: Why the need for XHTML?.
  15. Web site: How Did We Get Here? - Dive Into HTML5 . Pilgrim . Mark . diveintohtml5.info . 2016-06-11 . 2021-03-08 . https://web.archive.org/web/20210308073937/https://diveintohtml5.info/past.html . dead.
  16. Web site: 2008-12-29. Arjun Ray. 1999-10-06. ... However, since ISO 8879 does not afford applications the leeway to prohibit internal subsets, it follows that the letter of the HTML [4] spec automatically disentitles it to be a conforming SGML application.... Dropping the Normative Reference to SGML (was: I-D ACTION.). 2021-02-25. https://web.archive.org/web/20210225124458/https://markmail.org/message/drvncr3f6yscveeg. dead.
  17. Web site: XHTML—Myths and Reality . Tina Holmboe . The Developer's Archive . 2008-10-06 . 2008-12-29 . ... Since the design goals of XML itself partially mirrored those of the original HTML, it was logical for work to begin on formulating an XML–based markup language... . 2017-01-12 . https://web.archive.org/web/20170112181538/http://www.dev-archive.net/articles/xhtml.html . dead.
  18. Web site: Creating Web Utilities Using XML::XPath . Kip Hampton . XML.com . 2001-01-10 . 2008-12-29 . ... The problem: You want to take advantage of the power and simplicity that XML tools can offer, but you face a site full of aging HTML documents. The solution: Convert your documents to XHTML and put Perl and XML::XPath to work....
  19. Web site: Developing Wireless Content using XHTML Mobile . Jean-Luc David . XML.com . 2004-04-14 . 2008-12-29 . ... A useful feature of XHTML is that it can be manipulated as XML. Extensible Stylesheet Language Templates can be used to transform XHTML into WML or any other proprietary mobile formats....
  20. Web site: Namespaces Crash Course . Mozilla Developer Center . 2008-12-29 . ... It has been a long-standing goal of the W3C to make it possible for different types of XML-based content to be mixed together in the same XML file. For example, SVG and MathML might be incorporated directly into an XHTML-based scientific document... . 2008-10-02 . https://web.archive.org/web/20081002054459/http://developer.mozilla.org/En/SVG:Namespaces_Crash_Course . dead.
  21. Web site: HTML and XHTML Frequently Answered Questions . Steven Pemberton . . 2004-07-21 . 2008-12-29 . ... with an XML-based HTML other XML languages could include bits of XHTML, and XHTML documents could include bits of other markup languages. We could also take advantage of the redesign to clean up some of the more untidy parts of HTML and add some new needed functionality, like better forms....
  22. Web site: Comparison of SGML and XML . James . Clark . World Wide Web Consortium Note . 1997-12-15.
  23. Web site: Shorthand markup . HTML 4, Appendix B: Performance, Implementation, and Design Notes . W3C . 30 September 2011.
  24. Web site: Case Sensitivity . SitePoint Pty. Ltd . 30 September 2011.
  25. Web site: CSS differences between XHTML and HTML . Wilson . Nicholas. 29 May 2010 .
  26. Web site: XHTML 1.0 Specification, Appendix C: HTML Compatibility Guidelines . . 2000-01-26 . 2007-06-16.
  27. Web site: XHTML Media Types, W3C Working Group Note . . 2002-08-01 . 2008-06-12.
  28. Web site: Meta and Inline Tags that Google Understands Google Search Central.
  29. Greta de Groat (2002). "Perspectives on the Web and Google: Monika Henzinger, Director of Research, Google", Journal of Internet Cataloging, Vol. 5(1), pp. 17-28, 2002.
  30. Early implementations (such as Mozilla 0.7 and Opera 6.0, both released in 2001) do not incrementally render XHTML as it is received over the network, giving a degraded user experience; see the Mozilla Web Author FAQ. Later browsers such as Opera 9.0, Safari 3.0, and Firefox 3.0 do not have this issue.
  31. Web site: XHTML media type test - results . w3.org.
  32. Web site: The prolog, strict mode, and XHTML in IE . Chris Wilson . 2005-09-15 . 2007-06-16 . I've also been reading comments for some time in the IEBlog asking for support for the "application/xml+xhtml" MIME type in IE. I should say that IE7 will not add support for this MIME type – we will, of course, continue to read XHTML when served as "text/html", presuming it follows the HTML compatibility recommendations..
  33. Web site: The prolog, strict mode, and XHTML in IE . Chris Wilson . 2005-09-15 . 2007-06-16 . ...If we tried to support real XHTML in IE 7 we would have ended up using our existing HTML parser (which is focused on compatibility) and hacking in XML constructs. It is highly unlikely we could support XHTML well in this way; in particular, we would certainly not detect a few error cases here or there, and we would silently support invalid cases. This would, of course, cause compatibility problems based on parser error handling in the future, which XML is explicitly trying to avoid; we don't want to cause another mess like the one with current HTML error handling (rooted in compatibility with earlier browsers – you can blame me for that personally somewhat, but not IE). I would much rather take the time to implement XHTML properly after IE 7, and have it be truly interoperable....
  34. Web site: HTML5, Hardware Accelerated: First IE9 Platform Preview Available for Developers . 2019-03-16 . . Dean . Hachamovitch . . 2010-03-22 . ...At this time, we're looking for developer feedback on our implementation of HTML5's parsing rules, Selection APIs, XHTML support, and inline SVG. Within CSS3, we're looking for developer feedback on IE9's support for Selectors, Namespaces, Colors, Values, Backgrounds and Borders, and Fonts.....
  35. Web site: List of XHTML Sites (the X-Philes) . 2008-08-26 . 2008-11-20 . https://web.archive.org/web/20081120143513/http://www.goer.org/Markup/TheXPhiles . dead .
  36. http://sangers.nu/blog/tech/20080909-the-meta-tag-attribute--keywords "In 2007, 37 leaders in search engine optimisation concluded that having keywords in the keywords attribute is little to none." Sanger. nu blog, September 9, 2008, Retrieved August 2 2011
  37. Web site: Meta used for SEO . 18 December 2015 . March 18, 2016 . https://web.archive.org/web/20160331224917/http://nettrafficacademy.com/blog/meta-for-seo/ . March 31, 2016 . live.
  38. [Danny Sullivan (technologist)|Danny Sullivan]
  39. Web site: Sending XHTML as text/html Considered Harmful . . 2002-09-08 . 2007-06-16.
  40. Web site: XHTML is invalid HTML . Anne van Kesteren, a developer of the Opera browser . 2004-06-13 . 2007-06-16.
  41. Web site: Understanding HTML, XML, and XHTML . Maciej Stachowiak, a developer of Apple's Safari browser . 2006-09-20 . 2007-06-16.
  42. Web site: Sending XHTML as text/HTML Considered Harmful to Feelings . Brad Fults . 2005-12-21 . 2008-09-13 . There are not nearly as many disadvantages (if any) to sending XHTML as text/HTML as [Ian Hickson] claims and the advantages I mentioned above make it well worth using in my humble opinion. There are some subtle footnotes and parentheticals [in Hickson's article] indicating that the harmfulness only applies to authors that don't know the pitfalls of this practice, but much like the "Do not eat" label on the little packets of silica gel, Ian's advisory seems to be common sense and not worth mentioning to any author who actually knows what XHTML is and how to write it..
  43. Web site: The case for XHTML . Paul McDonald . 2007-06-30 . 2008-09-13 . Some people say XHTML on the Web has failed, but I say it is our biggest success in the fight for Web Standards. ... XHTML is a good thing for the web, though, and it's a shame that people are trying to make a case against it. To prove this, I'll flesh out the myth for you and then show you why XHTML is the best thing since sliced bread when it comes to our fight for Web Standards. ... So to conclude, sending XHTML as text/html causes no damage or harm anywhere today, as long as your XHTML does validate. And, if you want Web Standards to become more and more widespread, stick to using XHTML and validate your pages. . 2008-08-08 . https://web.archive.org/web/20080808134104/http://www.layouts4free.com/articles/view-article/49/3/0/ . dead.
  44. Web site: Reinventing HTML . Tim Berners-Lee . 2006-10-27 . 2007-06-16 . Some things are clearer with the hindsight of several years. It is necessary to evolve HTML incrementally. The attempt to get the world to switch to XML, including quotes around attribute values and slashes in empty tags and namespaces all at once didn't work. The large HTML-generating public did not move, largely because the browsers didn't complain. Some large communities did shift and are enjoying the fruits of well-formed systems, but not all. It is important to maintain HTML incrementally, as well as continue a transition to [a] well-formed world, and develop more power in that world.
    "The plan is to charter a completely new HTML group. Unlike the previous one, this one will be chartered to do incremental improvements to HTML, as also in parallel XHTML. It will have a different chair and staff contact. It will work on HTML and xHTML together. We have strong support for this group, from many people we have talked to, including browser makers. . dead . https://web.archive.org/web/20070609092703/http://dig.csail.mit.edu/breadcrumbs/node/166 . 2007-06-09.
  45. Web site: HTML5: A vocabulary and associated APIs for HTML and XHTML . Ian Hickson . David Hyatt . 2011-01-13 . 2011-02-16.
  46. Web site: Results of mobile tests . Simon Pieters . 2009-10-31.