Favorites

DOM Node.parentElement Property

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Node.parentElement
DOM Node PropertyThis property is supported by all modern browsers.
Updated 28th November 2026

The parentElement property returns the element that contains a node, or null.

Description

The read-only parentElement property returns the node's parent if it is an element, otherwise null. The only practical difference from parentNode is at the top of the tree: the <html> element's parentElement is null, because its parent is the document.

It's often used to walk up from an event target to a container, although closest() is usually shorter when you can describe the container with a selector. For nodes inside a document fragment, the top-level children's parentElement is null, because a fragment isn't an element.

Text nodes have a parentElement too, which is handy when working with selections or ranges, where you start from a text node and need the element that contains it.

Syntax

node.parentElement

Value

The parent element, or null if there is none or the parent isn't an element.

Example

<p>Some <em>emphasis</em> here.</p>
const em = document.querySelector('em');
console.log(em.parentElement.tagName, em.parentElement.parentElement.tagName);
console.log(document.documentElement.parentElement);

Browser Support

The following information will show you the current browser support for the Node.parentElement property. Hover over a browser icon to see the version that first introduced support for this property.

This property is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee