MENU
XHTML
Extensible HyperText Markup Language (XHTML) is a stricter version of HTML, in the sense that a document must be well-formed in the XML sense. Its development was motivated by interoperability with other formats, since an XHTML document can be processed by an XML processor. XML namespaces also let an XHTML document be extended by other XML-based languages, such as SVG and MathML.Two stable versions of XHTML exist: 1.0 and 1.1. XHTML 1.1 adds modularization, along with ruby annotation elements (ruby, rbc, rtc, rb, rt, and rp). XHTML is supported by all major browsers.
Besides the requirement to be well-formed in the XML sense, an XHTML document differs from an HTML document in several other important respects:
- An XHTML document begins with an XML declaration.
- The DOCTYPE declares the document to be XHTML-compliant.
- The root element, <html>, carries an xmlns attribute relating it to the XHTML namespace.
- All tag names and attribute names must be lowercase in XHTML.
- Attribute minimization is not allowed in XHTML. For instance, <textarea readonly> is incorrect; use <textarea readonly="readonly"> instead.
<?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">
<head>
<title>XHTML 1.0 Strict Example</title>
<script type="application/javascript">
<![CDATA[
function start() {
alert("Hello World");
}
]]>
</script>
</head>
<body onload="start()">
<p>The name of an XHTML file ends with .xhtml.</p>
</body>
</html>