text: What is XHTML, some of you may have heard the abbreviation and guess it has something to do with HTML and XML. That'd be a good guess. Below I hope to explain a little about what XHTML is, where it's come from, why it's a good thing, and how to use it when designing your web mark-up.
  But first, a quick definition care of the W3C:
  HTML 4 as been around for a while, it is the basis of the modern web, however it is far from perfect and far from supported. Most people know about browser incompatibilities, but what most people do not realise is that HTML has a standard grammar; it is just that browsers do not comply.
  Actually it is not the browser authors fault. To explain this we need first to look at a little history.
  SGML (Standard Generalized Markup Language) is a grammar used to mark-up documents for formatting, it was invented in the 1980's as a standard way of defining formats on electronic documents.
  HTML is an SGML application. That is, it is a set of mark-up that conforms to the SGML grammar and tells people (or computers) how to format a document. SGML says an element must look like this, an attribute like this, etc.
  As HTML evolved and the web became more popular, the SGML roots of HTML started to slip and browsers started allowing HTML authors get away with not conforming to the HTML standard. This was good for developers as it gives them an easier ride, however over time it adds inconsistencies between browsers and leaves us in the current mess of browser conformity.
  You've probably all heard of XML. It is a grammar like SGML, but it has been specifically designed for the Internet. It too defines how to structure documents in a rigid way, which makes it easy for programs (called XML parsers) to interpret XML documents. XHTML is an implementation of HTML as an XML application, in similar ways that HTML is an SGML application.
  The ultimate goal of XHTML is to allow browsers to do away with their HTML parsers and basically become XML (and XSL and CSS) parsers. This has two benefits:
  Browsers based on an XML parser can parse recommendation for over 2 years (since Jan 2000 to be exact). You can (and should) use it right now.
  "But why should I?" I hear you cry:
  You probably think that you can write proper HTML 4, I did, but if you haven't read and understood the HTML 4 spec then you can guarantee that your documents are not standard, try running your HTML through the HTML validator, you will be surprised, I know I was..
  text/html.
  text/xml
  Best practice is to get your server to check the types of files the browser will except and send the content as application/xhtml+xml to browsers that support it, and as text/html to those that don't.
  This rule exists for HTML 4 too, but browsers let you get away with missing it out, so most people do. The first line of any XHTML document should look like this:
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " DTD/xhtml1-transitional.dtd">
  This defines the document as XHTML 1 and tells the browser which DTD to use. There are three DTDs for XHTML, Transitional is the best to use if you are moving from HTML 4:
  is not valid XHTML. You must put quotes around the attribute body such:
  is not valid XHTML. You must close the tag like this:
  This is however annoying, so XML defines a shorthand way of closing empty tags like this:
  Even the humble line break tag must be closed, ie:
  So you cannot open two tags, and then close them in a different order, eg:
  is not valid, you must nest them correctly like:
  Last but not least and the hardest concept to get hold of, you must use tags in the correct context. When you place a tag in your document, it must have a parent that is valid for that tag. This is almost impossible to get right without practice or learning the XHTML spec inside out, so the best way to check if you have done something wrong is to check with the W3C validator.
  Now go forth and prepare your web sites for XML.
  XHTML 1.1 is the next version of the W3C XHTML specification for marking up Web pages, it became a W3C Recommendation in May, 2001.
  XHTML1.1 is a minor progression on from XHTML1.0. Essentially it is XHTML1.0 Strict with the deprecated elements removed. It should be sent with the application/xhtml+xml mime type but may be sent as text/html to non-supporting browsers that will interpret it as HTML4.
  XHTML1.1 should start with an XML declaration including an encoding type (especially if not UTF-8) followed by the XHTML1.1 DOCTYPE definition and then the "html" element including an XML namespaced language attribute.
  Here is an example of a very simple XHTML1.1 document:
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  "">
  <html xmlns="" xml:
  <head>
  <title>XHTML1.1@Everything2</title>
  </head>
  <body>
  <p>Moved to <a href=""></a>.</p>
  </body>
  </html>
  The goals of XHTML1.1 are to tidy up the last remaining messy ends from HTML4, but really doesn't add or change anything for the document author.
  Log in or register to write something here or to contact authors.
  Need help? accounthelp@everything2.com