# utils/dom/getpositionedancestor

module

<a id="functions">

## Functions

<a id="function-getPositionedAncestor">

### `getPositionedAncestor( element? ) → HTMLElement | null`

Returns the element the given one is laid out against while absolutely positioned – the element whose padding box its `top` and `left` are relative to. Returns `null` when there is nothing to compensate for: the element is laid out against the initial containing block, is `position: fixed`, or is not rendered at all.

Use it when turning a position measured against the viewport into the `top` and `left` to set on an absolutely positioned element, by subtracting the returned element's padding-box offset – the way [`toAbsoluteRect`](module_utils_dom_rect-Rect.md#function-toAbsoluteRect) and [`getOptimalPosition`](module_utils_dom_position.md#function-getOptimalPosition) do.

The layout-aware counterpart of `Element#offsetParent`, and what to reach for instead of it: this one follows the **flattened tree**, the one the browser lays out, so it stays right for slotted content – an editor slotted into a container component – where `offsetParent` names an element that does not lay that content out. Falls back to `offsetParent` for slotted content inside a closed root, whose slot the DOM standard does not expose.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/dom/getpositionedancestor.ts#L29)

#### Parameters

* `element?: HTMLElement`

  The native DOM element to be checked.

#### Returns

* `HTMLElement | null`

---

Full index of the CKEditor 5 API reference: [llms.txt](llms.txt)
