In JavaScript, the getClientRects() method returns a collection of DOMRect objects—one for each CSS border box of the element (MDN). Most elements have one box; a wrapping inline element can have one box per line.
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call el.getClientRects. Start with this line.
JavaScript
el.getClientRects()
Call
What it does
el.getClientRects()
Primary signature.
el.getClientRects(...)
Call with the arguments your case needs.
Built into the browser. Call getClientRects(...) on an Element — no import required.
Library declarations
JavaScript
el.getClientRects()
Parameters
This member has no parameters beyond those shown in the signature.
Count fragments.getClientRects().length can be > 1.
Measure the union.getBoundingClientRect() is one covering box.
Union height grows. It spans from the first line top to the last line bottom.
Pick by need. Per-line highlights → client rects; one tooltip box → bounding rect.
Compatibility
Browser Support
Element.getClientRects() is Baseline Widely available (MDN: across browsers since July 2015). Safe to use in modern evergreen browsers.
✓ Baseline · Widely available
getClientRects()
Returns one DOMRect per CSS border box — useful for multiline inline text.
99%Widely available
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
getClientRects()Excellent
Bottom line: Use getClientRects for per-line / per-box geometry; use getBoundingClientRect when one union box is enough.
Frequently Asked Questions
It returns a collection of DOMRect objects—one for each CSS border box associated with the element. Each rect describes size and viewport-relative position in pixels (MDN).
No. MDN marks Element.getClientRects() as Baseline Widely available (across browsers since July 2015). It is not Deprecated, Experimental, or Non-standard.
getClientRects() returns every border box (multiple for wrapped inline text). getBoundingClientRect() returns one DOMRect that is the union of all those boxes (MDN).
MDN: a multiline inline-level element (such as a wrapping span) has a border box around each line. A block-level paragraph usually has only one.
An empty list (length 0). MDN: elements that are not directly rendered—including display:none—return no rectangles.
Yes. Coordinates are viewport-relative and change when you scroll. Add scroll offsets if you need document coordinates.