XHTML

The educational technology and digital learning wiki
Jump to navigation Jump to search

Draft

Definition

  • XHTML is a family of current and future Web document types and modules that reproduce, subset, and extend HTML4.01. XHTML family document types are XML conformant, and designed to work in conjunction with XML-based editors and user agents.

See also:

XHTML documents

Valid XHTML documents

  • XHTML documents must be wellformed and valid according to the XML specification, except that an XML declaration is not mandatory (only encouraged).

In addition:

  • It must conform to the constraints expressed in one of the three variants (defined by DTDs)
  • The root element of the document must be html
  • The root element of the document must contain an xmlns declaration for the XHTML namespace. Examples:
 <html xmlns=  "http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<h:html xmlns:h="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  • There must be a DOCTYPE declaration in the document prior to the root element.
  • The DTD subset must not be used to override any parameter entities in the DTD.
  • An XML declaration on top of the file is mandatory if the character set used is different from UTF-8 or UTF-16.
XHTML Document structure

XHTML Versions

XHTML 1.0 (26 jan 2000, revised 1 Aug 2002)

According to the XHTML2 Working Group Home Page (retrieved 14:06, 1 September 2009 (UTC)), XHTML 1.0 is specified in three "flavors":

  • XHTML 1.0 Strict - Use this when you want really clean structural mark-up, free of any markup associated with layout. Use this together with W3C's Cascading Style Sheet language (CSS) to get the font, color, and layout effects you want.
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  • XHTML 1.0 Transitional - Many people writing Web pages for the general public to access might want to use this flavor of XHTML 1.0. The idea is to take advantage of XHTML features including style sheets but nonetheless to make small adjustments to your markup for the benefit of those viewing your pages with older browsers which can't understand style sheets. These include using the body element with bgcolor, text and link attributes.

<!DOCTYPE html

    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
</source>
  • XHTML 1.0 Frameset - Use this when you want to use Frames to partition the browser window into two or more frames.

<!DOCTYPE html

     PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
</source>
XHTML 1.1 additions (module-based XHTML)
  • XHTML Basic 1.1 is a mini-version of XHTML 1.0 for small devices (e.g. cell phones and PDAs). In principle, a successor for older WAP standards. Note there also exists a XHTML Mobile Profile which is a superset defined by the Open Mobile Alliance.
  • XHTML 1.1 is similar to XHTML 1.0 strict (but with a modular design).
XHTML 2.x - dead project
  • There were many new features, e.g. HTML forms, frames and DOM events will be replaced by XML standards
  • Any element can be a link
  • Nested <section> elements with a single heading element.
  • XHTML was quite a different language. Too much to cope for industry we believe, but in our opinion it was a better way to think about documents than HTML 4.x/XHTML 1.x - Daniel K. Schneider 14:06, 1 September 2009 (UTC).
HTML 5 - under development
  • Adds extra features to Both HTML 4.1 and XHTML 1.x

Example

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html 
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
   <title>Virtual Library</title>
 </head>
 <body>
   <p>Moved to <a href="http://example.org/">example.org</a>.</p>
 </body>
</html>

Composite documents

  • XHTML can include other namespaced languages, e.g. SVG or MathML or your own XML. However, for the moment it is not possible to validate composite documents.
MathML example
<?xml version="1.0" encoding="iso-8859-1"?>
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml">
 <xhtml:body>
   <xhtml:h1>A Compound Document</xhtml:h1>
   <xhtml:p>A simple formula using MathML in XHTML.</xhtml:p>
   <mathml:math xmlns:mathml="http://www.w3.org/1998/Math/MathML">
     <mathml:mrow>
       <mathml:msqrt>
         <mathml:mn>49</mathml:mn>
       </mathml:msqrt>
       <mathml:mo>=</mathml:mo>
       <mathml:mn>7</mathml:mn>
     </mathml:mrow>
   </mathml:math>
 </xhtml:body>
</xhtml:html>


  • It is also possible to include XHTML tags in any XML document markup. E.g. here is an example:
<?xml version="1.0" ?>
<?xml-stylesheet href="xml_plus_xhtml.css" type="text/css"?>
<page xmlns:html="http://www.w3.org/1999/xhtml" updated="jan 2007">
<title>Hello friend</title>
<list>
  <!-- we use an HTML tag below to include a picture -->
  <html:img src="photo.jpg"/>
  <item price="10"> White plate </item> 
  <item price="20"> Gold plate </item> 
  <item price="15"> Silver plate </item> 
</list>
<comment> Written by <html:a href="http://tecfa.unige.ch/tecfa-people/schneider.html">DKS/Tecfa</html:a> , feb 2007 </comment>
</page>

Current issues

XHTML is badly supported by IE6 and IE7. I.e. current (15:53, 12 March 2007 (MET)) Microsoft browsers do not recognize the application/xhtml+xml mimetype, which makes it difficult to include XSLT stylesheets or other languages such as SVG or MathML. The reason why MS doesn't support "real" XHTML is simple. They will have to rewrite the whole parser as it is explained by Chris Wilson in the IEBlog. So some day, there will be support.

If you send XHTML as simple HTML files you will loose all XML-related advantages.

There are workarounds to somewhat deal with IE 6/7:

 <?xml version="1.0" encoding="ISO-8859-1"?>
 <!-- prevent IE from rendering a DOM tree -->
 <?xml-stylesheet type="text/xsl" href="xhtml.xsl"?>
 <?xml version="1.0"?>
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
   <xsl:template match="/">
  <xsl:copy-of select="."/>
 </xsl:template>
 </xsl:stylesheet>

See Dean Edwards and Anne Van Kersteren

Tools

To author (X)HTML Pages you can:

Links

See HTML links (a page with links for both HTML and XHTML)

Standards

  • HTML, Latest Version (XHTML 1.0 as of 15:53, 12 March 2007 (MET)]
  • XHTML 1.0
  • XHTML Basic 1.1 (still a working draft as of March 2007).
  • XHTML 2.0 (working draft 2006). The project is dead: “2009-07-02: Today the Director announces that when the XHTML 2 Working Group charter expires as scheduled at the end of 2009, the charter will not be renewed. By doing so, and by increasing resources in the HTML Working Group, W3C hopes to accelerate the progress of HTML 5 and clarify W3C's position regarding the future of HTML.” (W3C news, retrieved 14:06, 1 September 2009 (UTC).

On-line tools