This page is Almost Ready

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.



Creates an empty Range instance object that has both of its boundary points positioned at the beginning of the document. After a Range is created, you must set its starting and ending boundary points before you can make use of most of its methods.

Method of dom/Documentdom/Document


var range = document.createRange();

Return Value

Returns an object of type DOM NodeDOM Node

An empty Range instance object.


//create a document range
var myRange = document.createRange();
//set starting and ending boundaries using predefined objects and variables
myRange.setStart(startNode, startOffset);
myRange.setEnd(endNode, endOffset);

Related specifications

DOM Level 2 Traversal and Range