9.3. The Root ElementXML and SGML documents have one and exactly one root element. It is the element that encloses all following elements. XHTML and HTML define html as the root element.
<html>...</html> Attributes
All elements in the document are contained within the root element (they are said to be descendants of the root element). As the root element, html may have no ancestors (in other words, it may not be contained within any other element). This example shows the root element from a minimal XHTML document: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" > Because this example is an XHTML document, the html element is also used to identify the XML namespace and language for the document, as discussed next. HTML documents do not use namespaces. 9.3.1. NamespaceAn XML namespace is a collection of element and attribute names as defined by the DTD of a particular markup language. In XML documents, you must explicitly identify the namespace so the client (in this case, the browser) knows that you intend the q element in your document to be a "quote" and not a "question" from some other (theoretical) XML language for exams. The namespace is specified using the xmlns attribute in the html root element. The value is the location of an online documentation of that namespace. The namespace identifier for XHTML 1.0 and 1.1 is xmlns="http://www.w3.org/1999/xhtml". 9.3.2. LanguageBecause this Web of ours is "World Wide," the HTML specifications take into account that documents are published in a variety of languages. For that reason, it is important to identify the language in which the document is written (as in lang="en") and the language of the XML version (as in xml:lang="en"). These attributes are placed in the html root element along with the namespace identifier. The XHTML 1.0 Recommendation suggests you include both attributes in the interest of backward compatibility. See Chapter 6 for a complete list of two-letter language codes. |