The Element.getAttributeNodeNS() method returns a namespaced attribute as an Attr node (MDN). Pass a namespace URI and a local name. Missing match → null. For the string only, use getAttributeNS().
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call el.getAttributeNodeNS. Start with this line.
JavaScript
el.getAttributeNodeNS(namespace, localName)
Call
What it does
el.getAttributeNodeNS(namespace, localName)
Primary signature.
el.getAttributeNodeNS(...)
Call with the arguments your case needs.
Built into the browser. Call getAttributeNodeNS(...) on an Element — no import required.
Same inputs. Both APIs take namespace + local name.
String path.getAttributeNS returns the value directly.
Node path.getAttributeNodeNS returns Attr for extra properties.
Pick by need. Values → NS string API; node details → this method.
Compatibility
Browser Support
Element.getAttributeNodeNS() is Baseline Widely available on MDN (across browsers since July 2015). It is not Deprecated, Experimental, or Non-standard.
✓ Baseline Widely available
Element.getAttributeNodeNS()
Namespaced Attr lookup by URI + local name. Core DOM — available everywhere modern.
2015+Widely available
Google ChromeAll modern
Supported
Mozilla FirefoxAll modern
Supported
Apple SafariAll modern
Supported
Microsoft EdgeAll modern
Supported
OperaAll modern
Supported
Internet ExplorerSupported
Supported
getAttributeNodeNS()Baseline
Bottom line: Safe for modern browsers and IE. Use for SVG/XML namespaces; prefer getAttributeNode for plain HTML.
Frequently Asked Questions
It returns the Attr node for a namespaced attribute on an element (MDN). You pass a namespace URI (or null) and the attribute’s local name.
No. MDN marks Element.getAttributeNodeNS() as Baseline Widely available (across browsers since July 2015). It is not Deprecated, Experimental, or Non-standard.
Two values: namespace (namespace URI string, or null for no explicit namespace) and localName (the attribute’s local name, for example "href").
getAttributeNS() returns the attribute value as a string (or null). getAttributeNodeNS() returns the Attr object so you can read name, value, namespaceURI, and ownerElement.
MDN: for HTML documents when you do not need a specific namespace, use getAttributeNode(). Use getAttributeNodeNS() for namespaced attributes (common in SVG and XML).
The method returns null when no attribute matches that namespace and local name.