localName (W3C DOM Core property)
var local = node.localName;
In the example above, if node is an
h1 element then the local variable
will have the value
"h1"; if node is
xml:id attribute1 then local will have
id; if it isn't an element or attribute then
local will be
In HTML, element names are returned in all uppercase, and attribute names in all lowercase, regardless of the case used in the document; in XML the case used in the document is preserved.
DOM 1 methods such as
getAttribute are not namespace aware, and
identify nodes by their
nodeName. Namespace aware DOM
2 methods such as
nodes by a combination of their
prefix combined form a qualified name
— a name which comprises the namespace prefix then the local name,
delimited with a colon.
This property is readonly.
Internet Explorer does not implement this property, and will return undefined.
localName is primarily an XML construct,
it's only reasonable to judge its behavior in terms of XML (either on
HTML pages in XHTML mode, or pure XML). The behavioral variations of
browsers in HTML mode3 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).
1 The W3C has published a
recommendation for an XML attribute called
which is universally of type
ID, and therefore if used
would remove the need for implementations to perform validation, or rely
on resource lookups or internal subsets. However only Opera 9 currently
implements this attribute.
2 On XHTML pages served as
3 On XHTML or HTML pages served as