W3cubDocs

/Web APIs

Document: caretRangeFromPoint() method

Non-standard: This feature is not standardized. We do not recommend using non-standard features in production, as they have limited browser support, and may change or be removed. However, they can be a suitable alternative in specific cases where no standard option exists.

The caretRangeFromPoint() method of the Document interface returns a Range object for the document fragment under the specified coordinates.

This method is the WebKit-proprietary implementation of the Document.caretPositionFromPoint method.

Syntax

caretRangeFromPoint(x, y)

Parameters

x

A horizontal position within the current viewport.

y

A vertical position within the current viewport.

Return value

One of the following:

  • A Range.
  • Null, if x or y are negative, outside viewport, or there is no text entry node.

Examples

Visit the Document.caretPositionFromPoint page to view a live sample of this method.

Specifications

Not part of any specification.

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
caretRangeFromPoint 4 12 No 15 5 18 No 14 4 1.0 4.4 4

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint