AbstractRange: endOffset property - Web APIs | MDN
Skip to search
AbstractRange: endOffset property
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2021.
See full compatibility
Report feedback
The
endOffset
property of the
AbstractRange
interface returns the offset into the end node of the range's end position.
To change the end position, use the
Range.setEnd()
method or a similar one.
Value
An integer value indicating the number of characters into the
Node
indicated by
endContainer
at which the final character of the range is located.
If the
endContainer
is a
Node
of type
Text
Comment
, or
CDATASection
, then the offset is the number of characters from the start of the
endContainer
to the boundary point of the range. For other
Node
types, the
endOffset
is the number of child nodes between the start of the
endContainer
and the boundary point of the range.
Example
js
const range = document.createRange();
range.setStart(startNode, startOffset);
range.setEnd(endNode, endOffset);
const endRangeOffset = range.endOffset;
Specifications
Specification
DOM
# ref-for-dom-range-endoffset①
Browser compatibility
Help improve MDN
Learn how to contribute
This page was last modified on
Jan 24, 2026
by
MDN contributors
View this page on GitHub
Report a problem with this content