I'm sure you've heard people mumbling about XHTML and how it combines HTML and XML to create the "next generation" of HTML. I too had heard the mumbling, but actually had no idea what XHTML was... up until about 2 months ago. In this article, Mitchell gives us a quick run down of what XHTML is, some of its benefits, how it can be used, and what it looks like. He wraps up the article with a couple of XHTML examples.
XHTML documents are backward compatible with older, non-XHTML compliant web browsers. Instead of sloppy HTML tags, your pages will now contain XML tags that are always properly closed and nested correctly, such as:
<p><b><u>This is some text<br /><br /></u></b></p>
<p><b><u>This is some text<br><br></b></u>
You can see that the XHTML version of the code above has a <p>, <b>, and then a <u> tag. These tags are closed in the reverse order that they were created in: </u>, </b>, and lastly </p>. All tags must be closed in this way for the XHTML document to be considered valid.
Also, notice the <br /> tags? Because of the way non-XHTML browsers are designed, as long as you leave a space between the beginning of the tag and the “/>”, then they will just treat the tag normally, and ignore the forward-slash.
XHTML is a standard
XHTML is an accepted standard (see http://www.w3.org/TR/xhtml1/), meaning that all of the newer browsers due for release over the next couple of months (such as newer version of IE, Netscape and Opera) will most definitely contain built-in support for XHTML.
The first document type in the XHTML family is XHTML 1.0. The W3C standard for XHTML takes three of the previous document types from HTML 4.0 and converts them to fully utilize XML wherever possible. This promotes a consistent, logical layout, while still keeping the actual content easy to follow.
XHTML documents must incorporate one of three document type definitions (DTD’s). This makes sure that the XML data contained within an XHTML document is valid and conforms to a certain layout/logical style as defined in that DTD file (more on DTD’s below).
You might be wondering what the benefits of migrating your current HTML documents over to XHTML are; you may also be wondering why you should bother learning more about XHTML; well, let me point out some of the benefits of XHTML (as listed at http://www.w3.org/TR/xhtml1/):
XHTML documents are XML conforming. As such, they are readily reviewed, edited and validated with standard XML tools such as the MSXML parser.
XHTML documents can be written to operate as well or better that they did before in existing HTML 4-conforming user agents as well as in new, XHTML 1.0 conforming user agents.
XHTML documents can utilize applications (e.g. scripts and applets) that rely upon either the HTML Document Object Model or the XML Document Object Model (DOM).