node.ownerDocument returns the top-level Document that owns the node(MDN). On a normal page element that is usually the same object as the global document. On a Document itself, it is null.
Status: Baseline Widely available (since July 2015) — not Deprecated, Experimental, or Non-standard. Read-only — you inspect ownership; you do not assign to it.
Remember
node.ownerDocument
→ Document that owns the node
→ or null when node is itself a Document
Page element:
el.ownerDocument === document → true
Document:
document.ownerDocument → null
Owned ≠ connected:
createElement(...) still has ownerDocument
isConnected may still be false
Read the owning document, then use it to create nodes or reach documentElement.
Start from any non-document node (element, text, …).
Read node.ownerDocument.
Use that Document for createElement / documentElement.
Remember: on a Document node the value is null.
Piece
Required?
Role
node
Yes
Any DOM Node
Return
—
Document, or null for Document nodes
Null check
If unsure
Needed when the node might be a Document
Pseudocode
Pseudocode
doc = node.ownerDocument
if doc is null:
// node is a Document
else:
html = doc.documentElement
el = doc.createElement("span")
// MDN-style climb:
d = p.ownerDocument
html = d.documentElement
// iframe-safe create:
doc = referenceNode.ownerDocument
sibling = doc.createElement("span")
Reference
Cheat Sheet
Keep these facts handy when working across documents.
Topic
Detail
Syntax
node.ownerDocument
Returns
Document or null
Mutates?
No — read-only
On Document
Always null (MDN)
Before append
Still set after createElement
vs parentNode
Owner document vs immediate parent
Standard
Baseline Widely available (since July 2015)
Try it
Live Preview
Compare ownerDocument on an element, the document itself, and a newly created node.
Demo
Hello
Starts from #od-demo. Document nodes report null for ownerDocument.
Result
Choose a target, then Run…
Code
JavaScript Examples
Short, copy-ready snippets based on MDN Node.ownerDocument. Use Try It Yourself for a live editor.
Example 1 — Element Owns the Page Document
On a normal page, an element’s owner is the global document.
One line:ownerDocument is the Document that owns a node — null on Document itself, and set even before the node is connected.
Frequently Asked Questions
The Document that owns the node — the top-level document object in which the node’s tree lives. For a normal page element, that is usually the same object as the global document.
No. MDN marks Node.ownerDocument as Baseline Widely available (since July 2015). It is a standard DOM property — not Deprecated, Experimental, or Non-standard.
When you read ownerDocument on a node that is itself a Document, MDN specifies the value is null. The document does not own another document above itself in this sense.
No. Nodes created with document.createElement still have ownerDocument set to that document, even before you append them (isConnected can still be false).
parentNode is the immediate parent (or null). ownerDocument is always the Document that owns the node (or null for Document nodes).
Yes. You read it to find the owning document; you do not assign to it.