name (W3C DOM Core property)

Version Depr. Static Read-only
DOM1 No No Yes
Browser support (more…)
IE5.5+ FF3+ SA3+ OP9+
Full Buggy Full Buggy


var attrs = document.documentElement.attributes;

for(var i=0; i<attrs.length; i++)
  var attrname = attrs[i].name;

In the example above we create a reference to the documentElement attributes collection, then we iterate through the collection numerically and retrieve the name of each individual attribute.


The name of an Attr. This is the name part of a name="value" pair.

For a namespaced attribute, the name property returns a qualified name1.

This property is read-only.


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 Buggy Buggy Buggy Full Buggy Buggy

In Opera 9.0 in HTML mode2 the name of an attribute is often returned in uppercase; a consistent pattern for when this does/doesn't occur could not be established, but appears to be related to whether that attribute has already been referred to in lower case (in which case its name is returned in lowercase, otherwise uppercase).

: The applicable node may not be available

In Internet Explorer 5.5 in HTML it's not possible to retrieve attribute nodes; however in situations where these objects are available their name always returns correctly, hence this property is considered fully supported.


1 A name comprised of the namespace prefix and local name, delimited with a colon, such as xml:lang.

2 On XHTML or HTML pages served as text/html.

User-contributed notes

There are no comments yet.

Related Products