This feature is not Baseline because it does not work in some of the most widely-used browsers.
The CaretPosition interface represents the caret position, an indicator for the text insertion point. You can get a CaretPosition using the Document.caretPositionFromPoint() method.
This interface doesn't inherit any properties.
CaretPosition.offsetNode Read only
Returns a Node containing the found node at the caret's position.
CaretPosition.offset Read only
Returns a long representing the offset of the selection in the caret position node. This will be the character offset in a text node or the selected child node's index in an element node.
CaretPosition.getClientRectReturns the client rectangle for the caret range.
| Specification |
|---|
| CSSOM View Module> # caret-position> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
CaretPosition |
128 | 128 | 20 | 114 | 18.4 | 128 | 20 | 85 | 18.4 | 28.0 | 128 | No |
getClientRect |
128 | 128 | 23 | 114 | 18.4 | 128 | 23 | 85 | 18.4 | 28.0 | 128 | No |
offset |
128 | 128 | 20 | 114 | 18.4 | 128 | 20 | 85 | 18.4 | 28.0 | 128 | No |
offsetNode |
128 | 128 | 20 | 114 | 18.4 | 128 | 20 | 85 | 18.4 | 28.0 | 128 | No |
© 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/CaretPosition