Newly available Newly available. Verify your target environments before adopting.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
128
128
20
26.2
128
26.2

The getClientRect() method of the CaretPosition interface returns the client rectangle for the caret range.

128
128
23
26.2
128
26.2

The offset property of the CaretPosition interface returns an integer representing the offset of the selection in the caret position node.

128
128
20
26.2
128
26.2

The offsetNode property of the CaretPosition interface returns a Node containing the found node at the caret's position.

128
128
20
26.2
128
26.2

The caretPositionFromPoint() method of the Document interface returns a CaretPosition object, containing the DOM node, along with the caret and caret's character offset within that node.

128
128
20
26.2
128
26.2
caretPositionFromPoint (options parameter)

`options` parameter

128
128
150
26.2
128
26.2
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)
Notes 1 item(s)
Removed
  • This feature was removed in a later browser version (133)

Use cases

  • Using document.caretPositionFromPoint()

    The CaretPosition interface represents the caret position, an indicator for the text insertion point.

Cautions

  • May not be supported in older browsers.

Implementation notes

  • Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.