HTML and CSS Reference
Local Namespaces in Compound Documents
One feature of XML is the ability to combine several languages into a single document.
For the elements of the different languages to coexist, you assign one language as the
default namespace for the document so that all elements are assumed to belong to that
language. Elements that do not belong to the default namespace belong instead to a
local namespace .
To define a local namespace, you add the attribute
xmlns: prefix =” namespace ”
to the root element of the XML document, where prefix is the prefix you'll use to mark
elements in this local namespace, and namespace is the namespace id. Every XML-
based language has a unique namespace id. For example, to declare a local namespace
for MathML within an XHTML document, you would add the following code to the html
This code sets the prefix for the namespace to the character string ml . Once you
define a namespace prefix, you place individual elements in that namespace by adding
the prefix to the element name in each markup tag as follows
< prefix : element >ƒ...ƒ</ prefix : element >
where prefix is the prefix for the local namespace and element is the name of the
element within that local namespace. For example, the following code contains the
paragraph element from XHTML and the mi , mo , and mn elements from MathML, all
coexisting within a single document:
Different browsers provide varying levels of support for different markup languages.
For instance, at the time of this writing, only Firefox and Opera provide built-in support
for MathML. The only requirement is that filenames including MathML elements use
either the .xml or .xhtml extension. Internet Explorer supports MathML through the use
of a browser add-in. WebKit browsers such as Safari and Google Chrome are promising
to provide built-in support for MathML in the near future.
MathML is also part of the design specifications for HTML5, and currently Firefox and
Opera both support MathML without the use of namespaces or namespace prefixes.
HTML5 and XHTML
HTML5 was developed to be backward compatible with earlier versions of HTML, and
also to support the common application of HTML syntax. The result is that many syntax
rules enforced in XHTML documents are not enforced in HTML5. Figure 9-14 summa-
rizes some of the differences between HTML5 and XHTML.