Education Online for Computer Software, Web Development, and Microsoft Office
Home  ->  Learn More About Web Dev, Software Applications, Microsoft Office, and Computers

Learn About XHTML


Cascading Style Sheets
Character encodings
Layout engine comparison
Dynamic HTML
Font family
HTML editor
HTML element
HTML scripting
Unicode and HTML
Web colors

Extensible HyperText Markup Language, or XHTML, is a markup language that has the same expressive possibilities as HTML, but a stricter syntax. Whereas HTML was an application of SGML, a very flexible markup language, XHTML is an application of XML, a more restrictive subset of SGML. Because they need to be well-formed (syntactically correct), XHTML documents allow for automated processing to be performed using a standard XML library ��" unlike HTML, which requires a relatively complex, lenient, and generally custom parser (though an SGML parser library could possibly be used). XHTML 1.0 became a World Wide Web Consortium (W3C) Recommendation on January 26, 2000.



The W3C offers this icon, which may be placed on valid XHTML documents once they pass through the W3C Markup Validator.
The W3C offers this icon, which may be placed on valid XHTML documents once they pass through the W3C Markup Validator.

XHTML is the successor to HTML ��" HTML is no longer being developed, while refinement of XHTML is ongoing. As such, XHTML may be considered by many to be the "current version" of HTML, but it is a separate, parallel standard; the W3C continues to recommend the use of either XHTML 1.1, XHTML 1.0, or HTML 4.01 for web publishing.

The need for a more strict version of HTML was felt primarily because World Wide Web content now needs to be delivered to many devices (like mobile devices) apart from traditional computers, where extra resources cannot be devoted to support the generosities of HTML.

Most of the recent versions of popular web browsers render XHTML properly, and many older browsers will also render XHTML as it is mostly a subset of HTML and most browsers do not require valid HTML. Similarly, almost all web browsers that are compatible with XHTML also render HTML properly. Some argue this compatability is slowing the switch from HTML to XHTML.

An especially useful feature of XHTML is that different XML namespaces (such as MathML and Scalable Vector Graphics) can be incorporated within it.

The changes from HTML to transitional XHTML are minor, and are mainly to achieve conformance with XML. The most important change is the requirement that the document must be well formed and all elements must be closed. Additionally, in XHTML, all tags must be written in lowercase. This is in direct contrast to established traditions which began around the time of HTML 2.0, when most people preferred uppercase tags. In XHTML, all attributes, even numerical ones, must be quoted. (This is optional in SGML, and hence in HTML, where quotes are not required if the content consists only of alphanumeric and certain allowed special characters.) All elements must also be closed, including empty elements such as img and br. This can be done by adding a closing slash to the start tag: <img … /> and <br />. Attribute minimization (e.g., <option selected>) is also prohibited; instead, use <option selected="selected">. More differences are detailed in the W3C XHTML specification [1].

Versions of XHTML


The original XHTML W3C Recommendation, XHTML 1.0, was simply a reformulation of HTML 4.01 in XML. There are three different 'flavors' of XHTML 1.0, each equal in scope to their respective HTML 4.01 versions.


The most recent XHTML W3C Recommendation is XHTML 1.1: Module-based XHTML. Authors can import additional features (such as framesets) into their markup. This version also allows for ruby markup support, needed for East-Asian languages (especially CJK).

This is the specification that the W3C recommends all new web pages be created in.

The XHTML 2.0 draft specification

Work on XHTML 2.0 is, as of 2005, still underway; in fact, the DTD has not even been authored yet. The XHTML 2.0 draft is controversial because it breaks backwards compatibility with all previous versions, and is therefore in effect a new markup language created to circumvent (X)HTML's limitations rather than being simply a new version.

New features brought into the HTML family of markup languages by XHTML 2.0 state that:

Others in the XHTML family

Validating XHTML documents

An XHTML document that conforms to the XHTML specification is said to be a valid document. In a perfect world, all browsers would follow the web standards and valid documents would predictably render on every browser and platform. Although validating your XHTML does not ensure cross-browser compatibility, it is recommended. A document can be checked for validity with the W3C Markup Validation Service.


For a document to validate, it must contain a Document Type Declaration, or DOCTYPE. A DOCTYPE declares to the browser what Document Type Definition (DTD) the document conforms to. A Document Type Declaration should be placed at the very beginning of an XHTML document. These are the most common XHTML Document Type Declarations:

XHTML 1.0 Strict
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
XHTML 1.0 Transitional
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
XHTML 1.0 Frameset
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"

The system identifier, which in these examples is the URL that begins with "http", need only point to a copy of the DTD to use if the validator cannot locate one based on the public identifier (the other quoted string). It does not need to be the specific URL that is in these examples; in fact, authors are encouraged to use local copies of the DTD files when possible. The public identifier, however, must be character-for-character the same as in the examples.

Character encoding may be specified at the beginning of an XHTML document in the XML declaration and within a meta http-equiv element. (If an XML document lacks encoding specification, an XML parser assumes that the encoding is UTF-8 or UTF-16, unless the encoding has already been determined by a higher protocol.)

Common errors

Some of the most common errors in XHTML are:

This is not an exhaustive list, but gives a general sense of errors that XHTML coders often make.

Backward compatibilities

XHTML 1.0 is backward compatible with HTML when served as text/html. However, there are problems associated, especially for Internet Explorer. For more information, please refer to XHTML section in the criticisms of Internet Explorer article. Furthermore, XHTML 2.0 has been faulted for not being backward compatible with XHTML 1.x efforts.


The following is an example of XHTML 1.0 Strict.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html 
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
<html xmlns="" xml:lang="en" lang="en">
        <title>XHTML Example</title>
        <p>This is tiny example of an XHTML usage.</p>

See also

External links

Wikibooks Programming has more about this subject:


Retrieved from ""
Personal tools
In other languages



All text is available under the terms of the GNU Free Documentation License (see Copyrights for details).