HTML DOM Range endOffset property

The endOffset property returns a number representing an Offset index where the Range ends. This is a read-only property.

If the parent node of Range is a Node of type Text then the offset index will be the index of ending character of the Range. For other Node types, the endOffset is the index of child nodes at the ending of the parent node.


end = range.endOffset;

Return Value: It returns a Offset index of ending of the range.

Example: In this example, we will use this property to get endOffset index.

Here the range’s endOffset index is 4th node from endContainer node.






<title>HTML DOM range endOffset property</title>   
<p>This is the Range Content</p>
    let range = document.createRange();
    let referenceNode = document.getElementsByTagName('p').item(0);


Output: In console, the endOffset Index can be seen.

Supported Browsers: 

  • Google Chrome
  • Edge
  • Firefox
  • Safari
  • Opera
  • Internet Explorer


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.