Definition of XHTML in Network Encyclopedia.
What is XHTML?
XHTML stands for Extensible Hypertext Markup Language, a proposed version of Hypertext Markup Language (HTML) from the World Wide Web Consortium (W3C). XHTML 1 is basically a reformulation of HTML 4 in Extensible Markup Language (XML) and can smooth the migration from HTML to XML by allowing developers to create HTML documents that contain XML functions.
The advantages of using XHTML instead of HTML for Web content development include the following:
- Easier portability to nonstandard user interfaces
- The ability to create new document type definitions (DTDs)
Web sites can already be migrated to XHTML because XHTML conforms to existing Hypertext Transfer Protocol (HTTP) user agents (Web browsers). Migrating ensures that content is XML-conforming, which is advantageous because XML is the future Web content paradigm.
Validating XHTML documents
An XHTML document that conforms to an XHTML specification is said to be valid. Validity assures consistency in document code, which in turn eases processing, but does not necessarily ensure consistent rendering by browsers. A document can be checked for validity with the W3C Markup Validation Service. In practice, many web development programs provide code validation based on the W3C standards.
The root element of an XHTML document must be
html, and must contain an
xmlns attribute to associate it with the XHTML namespace. The namespace URI for XHTML is
http://www.w3.org/1999/xhtml. The example tag below additionally features an
xml:lang attribute to identify the document with a natural language:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
In order to validate an XHTML document, a Document Type Declaration, or DOCTYPE, may be used. A DOCTYPE declares to the browser the Document Type Definition (DTD) to which the document conforms. A Document Type Declaration should be placed before the root element.
The system identifier part of the DOCTYPE, 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.
A character encoding may be specified at the beginning of an XHTML document in the XML declaration when the document is served using the
application/xhtml+xml MIME type. (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.)
<?xml version="1.0" encoding="UTF-8" ?>
The declaration may be optionally omitted because it declares as its encoding the default encoding. However, if the document instead makes use of XML 1.1 or another character encoding, a declaration is necessary. Internet Explorer prior to version 7 enters quirks mode, if it encounters an XML declaration in a document served as