prefix (W3C DOM Core property)
| Version | Depr. | Static | Read-only |
|---|---|---|---|
| DOM2 | No | No | No |
| IE5.5+ | FF1.5+ | SA3+ | OP9+ |
|---|---|---|---|
| Full | Full | Full | Full |
Example
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
The
example above shows the root element of an XHTML document. Its final
attribute has the nodeName
xml:lang, and therefore its
prefix is xml.
Description
The namespace prefix of this
node; or null if this node has no namespace.
Only namespaced elements and attributes have a prefix; for other
nodes, or for elements or attributes created with a non-namespace-aware
method such as createElement, the prefix property is null.
Changing
this value may also change the nodeName of this node
(since the node name of a namespaced node is a combination of of localName and prefix), as well as the
tagName and name properties of elements and attributes
(respectively).
Changing the prefix of an
element or attribute that has a default value in this document type does
not cause a new default node to be created (ie. the prefix change might
mean that the default is no longer present, but a new default will not
appear to replace it).
This property is read/write.
Compatibility
| Internet Explorer | Firefox | Safari | Opera | |||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 1.5 | 2.0 | 3.0 | 1.3 | 2.0 | 3.0 | 9.0 | 9.5 |
| Full | Full | Full | Full | Full | Full | Buggy | Buggy | Full | Full | Full |
In
Safari 1.3 and 2 the prefix
always returns null.
Since prefix is an XML construct, it's only
reasonable to judge its behavior in terms of XML (either on HTML pages
in XHTML mode1, or pure XML). The
behavioral variations of browsers in HTML mode2 are documented
here for interest and reference, but the support summary table above
does not consider this behavior (ie. if the property is fully
supported in XML then it's considered to be fully supported, with no
notes).
Internet Explorer does not implement this property in HTML, and will return undefined.
User-contributed notes
There are no comments yet.
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.