xmlns (HTML attribute)
| Depr. | Version |
|---|---|
| No | XHTML 1.0 |
| IE7 | FF1+ | SA3+ | OP9.2+ |
|---|---|---|---|
| None | Full | Full | Full |
Syntax
Example
Here the
xmlns attribute is used to define the default
namespace of an XHTML document:
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
Description
The
xmlns attribute on its own is used to declare the
default namespace URI for a document, which in an XHTML document will
always have the value "http://www.w3.org/1999/xhtml".
However this attribute is rather special in XML terms, because it’s also
used as a prefix to define additional namespaces for a document. For
example, the attribute xmlns:dc would declare a
namespace URI for elements with the prefix dc
(Dublin Core).
Value
The value of this attribute must be a fully-qualified URI (local paths and empty strings are not permitted). The URI will not be resolved when the document is parsed, and in fact it doesn’t need to point to an actual resource at all; the use of URIs is simply to ensure that namespaces are predictably unique to their creator.
Compatibility
| Internet Explorer | Firefox | Safari | Opera | |||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 1.0 | 1.5 | 2.0 | 1.3 | 2.0 | 3.0 | 9.2 | 9.5 |
| None | None | None | Full | Full | Full | None | None | Full | Full | Full |
Since namespaces are
an XML construct, it’s only reasonable to judge their behavior for HTML in
terms of XHTML documents served as XML; therefore Internet Explorer,
Safari 1.3 and Safari 2 must be considered to have no support for this
attribute, because they don’t support true XHTML. Over and above that, the
compatibility information shows which browsers recognise the
xmlns attribute as referring to the default
namespace.