files/en-us/web/api/range/getclientrects/index.md
{{ApiRef("DOM")}}
The Range.getClientRects() method returns a list of {{domxref("DOMRect")}} objects representing the area of the screen occupied by the range. This is created by aggregating the results of calls to
{{ domxref("Element.getClientRects()") }} for all the elements in the range.
getClientRects()
None.
An iterable sequence of {{domxref("DOMRect")}} objects.
<div></div>
<pre id="output"></pre>
div {
height: 80px;
width: 200px;
background-color: blue;
}
const range = document.createRange();
range.selectNode(document.querySelector("div"));
rectList = range.getClientRects();
const output = document.querySelector("#output");
for (const rect of rectList) {
output.textContent = `${output.textContent}\n${rect.width}:${rect.height}`;
}
{{EmbedLiveSample("Logging selected client rect sizes")}}
{{Specifications}}
{{Compat}}