docs.rodeo

MDN Web Docs mirror

Attr

{{APIRef("DOM")}} 

The Attr interface represents one of an element’s attributes as an object. In most situations, you will directly retrieve the attribute value as a string (e.g., {{domxref("Element.getAttribute()")}} ), but some cases may require interacting with Attr instances (e.g., {{domxref("Element.getAttributeNode()")}} ).

{{InheritanceDiagram}} 

The core idea of an object of type Attr is the association between a name and a value. An attribute may also be part of a namespace and, in this case, it also has a URI identifying the namespace, and a prefix that is an abbreviation for the namespace.

The name is deemed local when it ignores the eventual namespace prefix and deemed qualified when it includes the prefix of the namespace, if any, separated from the local name by a colon (:). We have three cases: an attribute outside of a namespace, an attribute inside a namespace without a prefix defined, an attribute inside a namespace with a prefix:

Attribute Namespace name Namespace prefix Attribute local name Attribute qualified name
myAttr none none myAttr myAttr
myAttr mynamespace none myAttr myAttr
myAttr mynamespace myns myAttr myns:myAttr

[!NOTE] This interface represents only attributes present in the tree representation of the {{domxref("Element")}} , being a SVG, an HTML or a MathML element. It doesn’t represent the property of an interface associated with such element, such as {{domxref("HTMLTableElement")}}  for a {{HTMLElement("table")}}  element. (See {{Glossary("Attribute", "this article")}}  for more information about attributes and how they are reflected into properties.)

Instance properties

This interface also inherits the properties of its parent interfaces, {{domxref("Node")}}  and {{domxref("EventTarget")}} .

Instance methods

This interface has no specific methods, but inherits the methods of its parent interfaces, {{domxref("Node")}}  and {{domxref("EventTarget")}} .

Specifications

{{Specifications}} 

Browser compatibility

{{Compat}} 

See also

In this article

View on MDN