coderef

document.caretPositionFromPoint()Baseline · Newly available

The document.caretPositionFromPoint() method finds an insertion point, represented by a DOM node and an offset within that node, for given coordinates in the viewport.

Works in the latest version of every major browser, but older devices may not support it yet. Baseline since Dec 12, 2025.

Browser support

DesktopChrome
1–127Not supported
128+Supportedsince Aug 20, 2024
Current: 155
Edge
12–127Not supported
128+Supportedsince Aug 22, 2024
Current: 154
Firefox
1–19Not supported
20+Supportedsince Apr 2, 2013
Current: 157
Safari
1–26.1Not supported
26.2+Supportedsince Dec 12, 2025
Current: 27
MobileChrome Android
18–127Not supported
128+Supportedsince Aug 20, 2024
Current: 155
Firefox Android
4–19Not supported
20+Supportedsince Apr 2, 2013
Current: 157
Safari iOS
1–26.1Not supported
26.2+Supportedsince Dec 12, 2025
Current: 27

How to use

Every current browser supports this, but it only became Baseline on Dec 12, 2025. Use it as a progressive enhancement, or keep a fallback if you support older devices.

Example

Full syntax and examples are on MDN: CaretPosition.

Feature detection

JS · check before using
if ("Document" in globalThis && "caretPositionFromPoint" in Document.prototype) {
  // Document.caretPositionFromPoint is available
}

Sub-features

Support for each part of the feature (6). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
CaretPosition1281282026.21282026.2
CaretPosition.getClientRect1281282326.21282326.2
CaretPosition.offset1281282026.21282026.2
CaretPosition.offsetNode1281282026.21282026.2
Document.caretPositionFromPoint1281282026.21282026.2
Document.caretPositionFromPoint.options_parameter12812815026.212815026.2