This article is from
Builder.com’s Design and Usability Tactics e-newsletter. Sign up instantly to begin receiving the Design and Usability
Tactics e-newsletter in your inbox.

It’s been more than four years since XHTML replaced HTML 4
as the standard markup for Web documents, according to the W3C, and yet most
Web builders still haven’t switched to XHTML. That’s a puzzling observation
considering that XHTML boasts several advantages over the older HTML standard,
and you can implement the new standard with only modest changes to your code.

Advantages of XHTML

XHTML is essentially a reinterpretation of HTML 4 as an XML
application. It takes the vocabulary of HTML and gives it the grammatical
structure of XML. It’s the first step in the transition of the Web to XML.

According to the W3C, the main advantages of XHTML are:

  • Extensibility: As an XML
    application, XHTML is extensible by definition. This makes future changes
    to the language much simpler in comparison to the process of changing
    HTML. Most browsers are already XML-compliant, so adding elements to the
    language is simply a matter of changing the document type definition and
    namespace. It’s no longer necessary to wait for browser developers to
    implement support for new elements.
  • Interoperability and portability:
    A properly structured XHTML document can be reformatted for use on a
    variety of display devices, including cell phones, PDAs, and other
    handheld devices. An XHTML document is also interoperable with other XML
    tools and applications.

These are both important advantages with significant
implications for the future of the Web, but they don’t mean much to most Web
builders. So, to bring things down to earth, here are my observations about
XHTML’s advantages over HTML:

  • Improves standardization: By
    imposing stricter rules on the way markup tags are used, XHTML removes
    some of the vagueness and inconsistency that has plagued HTML code. This
    makes it easier for browsers, search engines, and users to properly
    interpret the page markup.
  • Improves accessibility: XHTML
    documents are more accessible, which means that they work better with
    screen readers and other adaptive technologies. It also means that they
    score better with search engines.
  • Encourages cleaner code: XHTML
    continues the HTML 4 movement toward separating presentation from content.
    The XHTML markup designates document structure. Presentation is handled by
    CSS styles. This makes your Web sites easier to build and maintain.
  • Enforces best practices: Many of
    the recommended best practices for HTML are requirements in XHTML.
  • Makes more tools available: Since
    XHTML is an XML application, you can use any of the growing number of XML
    tools to develop, maintain, and transform your Web documents. You can use
    other XML applications (such as SVG) in XHTML documents, and you can use
    XML tools to do things such as transform an XHTML document into a PDF
    document.

This article is from
Builder.com’s Design and Usability Tactics e-newsletter. Sign up instantly to begin receiving the Design and Usability
Tactics e-newsletter in your inbox.

It’s been more than four years since XHTML replaced HTML 4
as the standard markup for Web documents, according to the W3C, and yet most
Web builders still haven’t switched to XHTML. That’s a puzzling observation
considering that XHTML boasts several advantages over the older HTML standard,
and you can implement the new standard with only modest changes to your code.

Advantages of XHTML

XHTML is essentially a reinterpretation of HTML 4 as an XML
application. It takes the vocabulary of HTML and gives it the grammatical
structure of XML. It’s the first step in the transition of the Web to XML.

According to the W3C, the main advantages of XHTML are:

  • Extensibility: As an XML
    application, XHTML is extensible by definition. This makes future changes
    to the language much simpler in comparison to the process of changing
    HTML. Most browsers are already XML-compliant, so adding elements to the
    language is simply a matter of changing the document type definition and
    namespace. It’s no longer necessary to wait for browser developers to
    implement support for new elements.
  • Interoperability and portability:
    A properly structured XHTML document can be reformatted for use on a
    variety of display devices, including cell phones, PDAs, and other
    handheld devices. An XHTML document is also interoperable with other XML
    tools and applications.

These are both important advantages with significant
implications for the future of the Web, but they don’t mean much to most Web
builders. So, to bring things down to earth, here are my observations about
XHTML’s advantages over HTML:

  • Improves standardization: By
    imposing stricter rules on the way markup tags are used, XHTML removes
    some of the vagueness and inconsistency that has plagued HTML code. This
    makes it easier for browsers, search engines, and users to properly
    interpret the page markup.
  • Improves accessibility: XHTML
    documents are more accessible, which means that they work better with
    screen readers and other adaptive technologies. It also means that they
    score better with search engines.
  • Encourages cleaner code: XHTML
    continues the HTML 4 movement toward separating presentation from content.
    The XHTML markup designates document structure. Presentation is handled by
    CSS styles. This makes your Web sites easier to build and maintain.
  • Enforces best practices: Many of
    the recommended best practices for HTML are requirements in XHTML.
  • Makes more tools available: Since
    XHTML is an XML application, you can use any of the growing number of XML
    tools to develop, maintain, and transform your Web documents. You can use
    other XML applications (such as SVG) in XHTML documents, and you can use
    XML tools to do things such as transform an XHTML document into a PDF
    document.

Practical differences in code

The syntax rules for XHTML are stricter than they were for
HTML 4. However, the differences aren’t large or difficult to understand. If
you’re in the habit of writing clean HTML code, the transition to XHTML will be
an easy one.

The following list summarizes the major code differences
between HTML and XHTML:

  • Including
    the processing instruction line (the XML prolog) is recommended, but not
    required:

<?xml version=”1.0″ encoding=”iso-8859-1″?>

  • Doctype
    declaration is required:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

  • Namespace
    designation is required:

<html >

  • Html,
    head, body, and title elements are required:

<html>

    <head>
        <title>Page Title</title>
    </head>
    <body>

    </body>
</html>

  • Tags
    and attributes must be lowercase:

<p class=”bodytxt”>

  • Attribute
    values must be quoted:

font-size=”large”

  • Non-empty
    tags must be terminated with a closing tag:

<p>text</p>

  • Empty
    tags (e.g., hr, br, img) must incorporate a slash:

<br />

  • Elements
    can’t overlap—they must nest properly:

<em><strong>text</strong></em>

This isn’t a complete list of code differences between HTML
and XHTML, but it includes most of the common issues. I’ll cover proper XHTML
coding in more detail in future columns.

What are you waiting for?

Given the advantages of XHTML, there’s really no reason not
to use it. The coding differences between HTML and XHTML shouldn’t be an
obstacle because they’re relatively small and easy to learn. Furthermore, newer
versions of popular Web development software, such as Dreamweaver MX, now
include at least basic XHTML support, which means that XHTML probably won’t
require much more hand coding than HTML.

Granted, rewriting existing Web pages to comply with the
XHTML standard would be a time-consuming chore that isn’t likely to result in a
dramatic improvement in visitor experience. But there’s no reason not to use
XHTML for your new pages. XHTML is the path to the future of the Web, so get
with the program.

Practical differences in code

The syntax rules for XHTML are stricter than they were for
HTML 4. However, the differences aren’t large or difficult to understand. If
you’re in the habit of writing clean HTML code, the transition to XHTML will be
an easy one.

The following list summarizes the major code differences
between HTML and XHTML:

  • Including
    the processing instruction line (the XML prolog) is recommended, but not
    required:

<?xml version=”1.0″ encoding=”iso-8859-1″?>

  • Doctype
    declaration is required:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

  • Namespace
    designation is required:

<html >

  • Html,
    head, body, and title elements are required:

<html>

    <head>
        <title>Page Title</title>
    </head>
    <body>

    </body>
</html>

  • Tags
    and attributes must be lowercase:

<p class=”bodytxt”>

  • Attribute
    values must be quoted:

font-size=”large”

  • Non-empty
    tags must be terminated with a closing tag:

<p>text</p>

  • Empty
    tags (e.g., hr, br, img) must incorporate a slash:

<br />

  • Elements
    can’t overlap—they must nest properly:

<em><strong>text</strong></em>

This isn’t a complete list of code differences between HTML
and XHTML, but it includes most of the common issues. I’ll cover proper XHTML
coding in more detail in future columns.

What are you waiting for?

Given the advantages of XHTML, there’s really no reason not
to use it. The coding differences between HTML and XHTML shouldn’t be an
obstacle because they’re relatively small and easy to learn. Furthermore, newer
versions of popular Web development software, such as Dreamweaver MX, now
include at least basic XHTML support, which means that XHTML probably won’t
require much more hand coding than HTML.

Granted, rewriting existing Web pages to comply with the
XHTML standard would be a time-consuming chore that isn’t likely to result in a
dramatic improvement in visitor experience. But there’s no reason not to use
XHTML for your new pages. XHTML is the path to the future of the Web, so get
with the program.