DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Coding
  3. Languages
  4. Where has XHTML gone?

Where has XHTML gone?

Giorgio Sironi user avatar by
Giorgio Sironi
·
Feb. 01, 11 · Interview
Like (0)
Save
Tweet
Share
9.88K Views

Join the DZone community and get the full member experience.

Join For Free

When I started working in the web development field, XHTML had recently been introduced and was all the rage. I even included XHTML templates and a copy of the DTD in our enterprise CMS, believing that in some years the publicly hosted DTD would be targeted by millions of users browsers, trying to validate XHTML code and rejecting malformed documents.

But now in 2011, where XHTML has gone?

What XHTML is

XHTML is a specification which defines the XML serialization of HTML: while HTML itself is not a strict language, and ignore most of the malformed tags and nesting structures, XML is much more draconian. In its original versions, XHTML 1 and 2, XHTML was the reformulation of HTML 4 in order to transform HTML documents in valid XML ones, agnostic with respect to the graphic presentation or the media type.

For example, XHTML deprecated or invalidated all tags strictly related to presentation issues, like <b> (substituted by <strong>) but also <font>. Ideally, XHTML documents could just be viewed on different medias by specifying a different CSS.

An interesting idea of XHTML was also providing different modules, via XML namespaces. You are able to compose different markup languages in a document, in addition to the standard one: a language for forms, one for mathematical formulas, one for vector graphics.

Here's an example of XHTML snippet, including a MathML expression.

<p>Some random text.</p>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<plus/>
<apply>
<times/>
<ci>a</ci>
<apply>
<power/>
<ci>x</ci>
<cn>2</cn>
</apply>
</apply>
<apply>
<times/>
<ci>b</ci>
<ci>x</ci>
</apply>
<ci>c</ci>
</apply>
</math>

A bit verbose, but comparing to using cryptic LaTeX notation, which must be parsed on the server-side, it's not so ugly.

The approach of HTML 5 has been instead to provide support directly into a single specification: the <input> element has been extended to provide user-friendly forms without the need for additional JavaScript libraries; <canvas> can be used for SVG; and so on. The DOM is also manipulable via JavaScript, in an important part of the spec.

Another advantage of XHTML may be the use of XML tools for web pages too: in every language you have an XML parser, but an HTML one is more difficult to find or write.

The issues

XHTML 1.0 dates back to 2000. If it is so powerful, why it has not been widely adopted?

I think here's why:

XML has a very strict syntax with respect to SGML-derived languages like HTML. If there is a syntax error or a missing closing tag or attribute double quote in even one row of your XHTML document, it won't be interpreted by the browser.

Moreover, character encoding and JavaScript access to the DOM is more difficult in XHTML documents: try write a & character or access an element without its XHTML namespace.

The Facebook case

Facebook includes an XHTML 1.0 strict doctype in each page. However, it serves documents with the text/html HTTP response header, which means browser do not treat the content as XML.

XHTML has spreaded in Facebook in the last years: the last time I saw it was as FBML, a language used to extend the capabilities of Facebook applications on the client side. FBML tags are included in an XML namespace and are interpreted via JavaScript to produce an effect (not by the browser by itself).

For example, the following snippet produces a friend selector, of course customized for the current user:

<form action="http://www.example.com/handler.php" id="testForm" method="post">
<fb:friend-selector uid="12345" name="uid" idname="grab_me_please" prefill_id="7906796"/>
<input type="submit" value="test" />
</form>


Rather then resorting to custom attributes over standard tags like many JS frameworks do, this declarative approach adds a fb XHTML namespace and makes available a whole new set of tags with extended capabilities. And it uses a well-documented standard, like XHTML.

However Facebook is in the process of deprecating FBML (moving to iframe-based applications), and preaches to just use more widely adopted standard: HTML and CSS. The same feature of FBML are now available via a JavaScript SDK and by a bunch of Social Plugins.

XHTML5!

Just when you thought XHTML may disappear, I have to tell you that XHTML has been evolved to accomodate the HTML 5 specification. You can write (only if you really want, of course) HTML 5 as valid XML. However it seems that XHTML 5 will try to remain backward compatible with HTML, for example by allowing elements like <i> and <font> in certain use cases.

As a web developer, will you use XHTML [5] in the future?

Resources

http://xhtml.com/en/future/x-html-5-versus-xhtml-2/

http://www.w3.org/MarkUp/2004/xhtml-faq#advantages admits that translating an HTML document in XHTML won't result in a difference, unless you incude other languages.

Wikipedia's article on MathML shows you an example of a language that can be used in an XHTML document as a module.

XHTML HTML XML Document

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Journey to Event Driven, Part 1: Why Event-First Programming Changes Everything
  • 10 Things to Know When Using SHACL With GraphDB
  • Distributed Tracing: A Full Guide
  • What Is JavaScript Slice? Practical Examples and Guide

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: