Element.removeAttributeNode() is an instance method that removes an Attr node from an element and returns that node. Learn the MDN lang workflow with getAttributeNode(), when to prefer removeAttribute(), and five try-it labs aligned with MDN.
01
Kind
Instance method
02
Arg
Attr node
03
Returns
removed Attr
04
Error
NotFoundError
05
vs removeAttr
name vs node
06
Status
Baseline widely
Fundamentals
Introduction
Most code deletes attributes with removeAttribute("lang"). The removeAttributeNode() variant takes an Attr node instead of a name. MDN: it removes the specified Attr node from the element.
Use it when you already have an Attr object—for example from getAttributeNode()—and want to inspect it before removal or keep the removed node in a variable.
💡
Beginner tip
MDN: if you do not need to inspect the attribute node first, use removeAttribute() instead. It is simpler for everyday tasks.
Element.removeAttributeNode() is Baseline Widely available (MDN: across browsers since July 2015). Logos use the shared browser-image-sprite.png sprite from this project.
✓ Baseline Widely available
Element.removeAttributeNode()
Remove an Attr node from an element — returns the removed node.
BaselineWidely available
Google ChromeSupported · Desktop & Mobile
Yes
Microsoft EdgeSupported · Chromium
Yes
Mozilla FirefoxSupported · Desktop & Mobile
Yes
Apple SafariSupported · macOS & iOS
Yes
OperaSupported · Modern versions
Yes
Internet ExplorerSupported in legacy IE
Yes
removeAttributeNode()Excellent
Bottom line: Use removeAttributeNode() when you have an Attr object. For everyday deletes, removeAttribute(name) is simpler.
Wrap Up
Conclusion
Element.removeAttributeNode() removes an Attr node from an element and returns that node—ideal when you already have the attribute object. For everyday deletes, removeAttribute() is simpler; use removeAttributeNode() when you need to inspect or archive the Attr first.
Get the Attr from the same element you remove from
Null-check after getAttributeNode() before removing
Use the returned Attr to log or archive old values
Prefer removeAttribute() when you only know the name
Wrap in try/catch when Attr ownership is uncertain
❌ Don’t
Pass an Attr from a different element
Use everywhere when removeAttribute() suffices
Forget NotFoundError for wrong Attr nodes
Assume removed attrs never get default values back (MDN note)
Confuse this with removing the element (remove())
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about Element.removeAttributeNode()
Remove by Attr node, not by name.
5
Core concepts
📝01
Parameter
Attr node
API
📄02
Returns
removed Attr
Result
✍️03
Pair
getAttributeNode
Workflow
⚠️04
Error
NotFoundError
Throws
⚡05
Default
removeAttribute
Simpler
❓ Frequently Asked Questions
It removes the specified Attr node from the element and returns that removed Attr node (MDN).
No. MDN marks Element.removeAttributeNode() as Baseline Widely available (across browsers since July 2015). It is not Deprecated, Experimental, or Non-standard.
An Attr node — typically obtained first with getAttributeNode() or from element.attributes (MDN).
The Attr node that was removed from the element (MDN).
MDN: if you do not need to inspect the Attr node before removing it, removeAttribute(attrName) is simpler.
NotFoundError when the element's attribute list does not contain the specified Attr node (MDN).
Did you know?
MDN notes that after you remove an attribute, the browser may immediately replace it with a default value for that attribute on the element type. Also, removeAttributeNode() works for namespaced attributes —there is no separate removeAttributeNodeNS method.