Element.removeAttributeNS() removes an attribute in a given namespace from the element (MDN). For ordinary HTML without a namespace, prefer removeAttribute(). Returns undefined.
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call el.removeAttributeNS. Start with this line.
JavaScript
el.removeAttributeNS(namespace, attrName)
Call
What it does
el.removeAttributeNS(namespace, attrName)
Primary signature.
el.removeAttributeNS(...)
Call with the arguments your case needs.
Built into the browser. Call removeAttributeNS(...) on an Element — no import required.
const el = document.getElementById("box");
// Everyday HTML — no namespace
el.removeAttribute("title");
// Only when you truly need a namespace
// el.removeAttributeNS(NS, "localName");
Call removeAttribute. One argument — the name (MDN).
Reserve NS APIs for SVG / XML / custom namespaces.
Same idea as set:setAttribute vs setAttributeNS.
Compatibility
Browser Support
Element.removeAttributeNS() is Baseline Widely available on MDN (across browsers since July 2015). Safe for SVG/XML namespace work.
✓ Baseline Widely available
Element.removeAttributeNS()
Remove a namespaced attribute by URI and local name — widely supported.
WideBaseline
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
Android WebViewSupported · Modern WebView
Full support
removeAttributeNS()Widely available
Bottom line: Use for real namespaces (SVG/XML). Prefer removeAttribute() for ordinary HTML attributes.
Frequently Asked Questions
It removes the specified attribute with the specified namespace from an element (MDN).
No. MDN marks Element.removeAttributeNS() as Baseline Widely available (across browsers since July 2015). It is not Deprecated, Experimental, or Non-standard.
namespace — a string with the attribute namespace URI. attrName — the attribute’s local name to remove (MDN example uses specialAlign, not the prefix).
MDN: if you work with HTML and do not need to specify the attribute as part of a namespace, use removeAttribute(attrName) instead.
undefined. There is no return value (MDN).
Call hasAttributeNS(namespace, localName) afterward. It should return false when the namespaced attribute is gone.