namespaceURI property

String? get namespaceURI

The read-only namespaceURI property of the Attr interface returns the namespace URI of the attribute, or null if the element is not in a namespace.

The namespace URI is set at the Attr creation and cannot be changed. An attribute with a namespace can be created using Element.setAttributeNS.

Note: an attribute does not inherit its namespace from the element it is attached to. If an attribute is not explicitly given a namespace, it has no namespace.

The browser does not handle or enforce namespace validation per se. It is up to the JavaScript application to do any necessary validation. Note, too, that the namespace prefix, once it is associated with a particular attribute node, cannot be changed.

Implementation

external String? get namespaceURI;