Home arrow HTML arrow Page 6 - XHTML 2.0 Explained

XHTML 2.0 Explained

Although XHTML 2.0 isn't ready for general use yet, understanding how the changes will affect your writing and code will be key to a smooth transition. With full XForms integration, separation of content and function, and other features, XHTML 2.0 promises to revolutionize the Web when XHTML 2.0 arrives.

Author Info:
By: Sasha Slutsker
Rating: 4 stars4 stars4 stars4 stars4 stars / 30
August 24, 2004
  1. · XHTML 2.0 Explained
  2. · Making the Switch
  3. · Get Ready for New Types of Lists
  4. · Sections and Headings
  5. · XForms
  6. · The MIME Situation

print this article

XHTML 2.0 Explained - The MIME Situation
(Page 6 of 6 )

What is a MIME type?

A MIME type is used to specify what kind of file something is and is sent to the browser from the server. It tells the computer what type of document it is so that the computer can choose the proper application to open the document with. For example, "text/html" is an HTML file and "image/png" is a PNG image.

XHTML and MIME types

When writing XHTML in the past, it was possible to use the MIME type text/html if you wanted to. This meant that the browser will interpret it as HTML, not really XHTML. When a browser is interpreting XHTML and it is not well-formed, it is supposed to spit out an error message. The proper MIME type is application/xhtml+xml for XHTML documents. The problem is that Internet Explorer remains the only popular browser not to support this MIME type (mainly because Internet Explorer uses filename extensions instead of MIME types usually), which means that these MIME types are used less frequently than they probably should be used.

Will XHTML 2.0 require application/xhtml+xml?

In the latest draft, it was not said whether XHTML will require this MIME type or not. In the past, it has merely been recommended by the draft. Since Internet Explorer does not support the application/xhtml+xml MIME type, it could present problems if it is going to be required. One way to get around it would be to send a different MIME type to Internet Explorer using server-side technologies listed below. Many websites already do this, so it does make some sense.

Serving different MIME types to different browsers using PHP

The server sends a header called HTTP_ACCEPT to the browser which says what MIME types it allows. It is possible to take this and use it to tell if the browser support application/xhtml+xml using any server-side technology. Here, we will use PHP to show how easy it is to do.

if (stristr($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml'))
 header('Content-Type: application/xhtml+xml');
 header('Content-Type: text/html');

Now, this isn't the perfect solution, since some browsers may claim to have support, but that support may not be that good. Still, it is a pretty good solution to the MIME type problem.


Now that you have seen XHTML 2.0 introduced to you, I am sure you will use it once it is been released. It isn't as important now since no browsers support it and it isn't even finished yet, but learning it now will prepare you for its arrival. Plus, with CSS, it is possible to define most of the XHTML 2.0 tags yourself and make a working page using most of the new XHTML features. (I doubt you could get XForms and similar things working in these situations.)

Once XHTML 2.0 officially released, it will be easy to make interoperable pages that are made accessible to all users. This is because, though achieving full content/layout separation has long been a goal, it has not quite been achieved before now. Now, with XHTML 2.0, this will finally be possible.

Here is a very simple page using the techniques described in this tutorial. It will not actually work in a browser, since none support XHTML 2.0. However, it should give you an idea of how XHTML 2.0 will look.

if (stristr($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml'))
 header('Content-Type: application/xhtml+xml');
 header('Content-Type: text/html');

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 2.0//EN" "http://www.w3.org/TR/xhtml2/DTD/xhtml2.dtd"> 
<html xmlns="
http://www.w3.org/2002/06/xhtml2" xml:lang="en">
 <title>XHTML 2.0 Page</title>
   <h>Welcome to an XHTML 2.0 Page!</h>
    <h>No browsers support XHTML 2.0 yet</h>
    <p>But it's still fine</p>
    <h>Cool Stuff</h>
     <line>There is no hr element, instead...</line>
     <separator />
      <label>Links to sites</label>
      <li href = "http://example.com">Link 1</li>
      <li href = "http://example.com">Link 2</li>
     </nl>                                            </p>

DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus

- Does HTML5 Need a Main Element?
- Revisiting the HTML5 vs. Native Debate
- HTML5: Not for Phone Apps?
- HTML5 or Native?
- Job Hunting? Freelancer.com Lists This Quart...
- HTML5 in the News
- Report: HTML5 Mobile Performance Lags
- The Top HTML5 Audio Players
- Top HTML5 Video Tutorials
- HTML5: Reasons to Learn and Use It
- More of the Top Tutorials for HTML5 Forms
- MobileAppWizard Releases HTML5 App Builder
- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials