HTML
  Home arrow HTML arrow Page 6 - XHTML 2.0 Explained
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
Moblin 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
IBM developerWorks
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
HTML

XHTML 2.0 Explained
By: Sasha Slutsker
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 26
    2004-08-24

    Table of Contents:
  • XHTML 2.0 Explained
  • Making the Switch
  • Get Ready for New Types of Lists
  • Sections and Headings
  • XForms
  • The MIME Situation

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    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.

    <?php
    if (stristr($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml'))
     header('Content-Type: application/xhtml+xml');
    else
     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.

    Conclusion

    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.

    <?php
    if (stristr($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml'))
     header('Content-Type: application/xhtml+xml');
    else
     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">
    <head>
     <title>XHTML 2.0 Page</title>
    </head>
     <body>
      <section>
       <h>Welcome to an XHTML 2.0 Page!</h>
       <section>
        <h>No browsers support XHTML 2.0 yet</h>
        <p>But it's still fine</p>
       </section>
       <section>
        <h>Cool Stuff</h>
        <p>
         <line>There is no hr element, instead...</line>
         <separator />
         <nl>
          <label>Links to sites</label>
          <li href = "http://example.com">Link 1</li>
          <li href = "http://example.com">Link 2</li>
         </nl>                                            </p>
       </section>
      </section>               
     </body>
    </html>


    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.

       · It is me, the writer of the article. I just want to add that there are some examples...
       · is is just me or is anyone else thinking xhtml 2.0 is stupid.Removing <br/>Come...
       · I think it's just you. I welcome these standards as a way to help clean up the...
       · Crappy coding has very little to do with XHTML standards.And more to do with...
       · Please Kndly give a space like <br />It works now my dear.Happy...
       · Since i have made server side scripts, I hate many objects that makes much more work...
       · Who matters? Money-grubbing megacorps that are frozen in 1995 and know nothing...
       · "Removing <br/>Come on, now I have to type 5 times the code for a simple line...
       · "Seperation of content and style is one thing, but making thingslonger and harder...
       · If your scripts aren't flexible enough to allow this simple transition, then they're...
       · The space isn't necessary for anything in common use today (for example Netscape 4...
       · I have study all the documents for XHTML 2.0. But I am getting confusion here for...
     

    HTML ARTICLES

    - Building Single Row Database Forms with HTML
    - Introduction to Database Forms with HTML
    - Another Look at Animation of Geographical Ma...
    - Animation of Geographical Map Regions
    - Changing and Moving Pictures with CSS
    - Clickable Geographical Map Regions
    - Gradient Creation with the HR Element
    - Text on HTML Images: Do it Yourself
    - Custom Buttons in HTML
    - Quick Web Page Menu
    - Maximizing and Restoring HTML Images with th...
    - Maximizing and Restoring HTML Images with th...
    - Handling Hyperlinks and Images in HTML
    - Quick Start with HTML
    - HTML Tips







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway