# parentNode property

The `parentNode` property contains the parent element. There is also an almost identical `parentElement` property. Differences: for the `html` tag, the `parentNode` property returns `document`, while `parentElement` returns `null`.

## Syntax

`element.parentNode;`

## Example

Let's get the parent of the `#elem` element and display its `id`:

`<div id="parent"> <p id="elem"></p> </div>` `let elem = document.querySelector('#elem'); let id = elem.parentNode.id; console.log(id);`

The code execution result:

`'parent'`

## See also

- the `parentElement` property
  that defines a parent element

← →
↑
en ru