This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
Note: This feature is available in Web Workers.
A DOMRect describes the size and position of a rectangle.
The type of box represented by the DOMRect is specified by the method or property that returned it. For example, Range.getBoundingClientRect() specifies the rectangle that bounds the content of the range using such objects.
It inherits from its parent, DOMRectReadOnly.
DOMRect()Creates a new DOMRect object.
DOMRect inherits properties from its parent, DOMRectReadOnly. The difference is that they are not read-only anymore.
DOMRect.xThe x coordinate of the DOMRect's origin (typically the top-left corner of the rectangle).
DOMRect.yThe y coordinate of the DOMRect's origin (typically the top-left corner of the rectangle).
DOMRect.widthThe width of the DOMRect.
DOMRect.heightThe height of the DOMRect.
DOMRectReadOnly.topReturns the top coordinate value of the DOMRect (has the same value as y, or y + height if height is negative).
DOMRectReadOnly.rightReturns the right coordinate value of the DOMRect (has the same value as x + width, or x if width is negative).
DOMRectReadOnly.bottomReturns the bottom coordinate value of the DOMRect (has the same value as y + height, or y if height is negative).
DOMRectReadOnly.leftReturns the left coordinate value of the DOMRect (has the same value as x, or x + width if width is negative).
DOMRect may also inherit static methods from its parent, DOMRectReadOnly.
DOMRect.fromRect()Creates a new DOMRect object with a given location and dimensions.
DOMRect may inherit methods from its parent, DOMRectReadOnly.
| Specification |
|---|
| Geometry Interfaces Module Level 1> # DOMRect> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
DOMRect |
61 | 79 | 31 | 48 | 10.1 | 61 | 31 | 45 | 10.3 | 8.0 | 61 | 10.3 |
DOMRect |
612–61 | 7912–79 | 273–27 | 489.5–48 | 10.14–11 | 6118–61 | 274–27 | 4510.1–45 | 10.33.2–11 | 8.01.0–8.0 | 612–61 | 10.33.2–11 |
fromRect_static |
61 | 79 | 69 | 48 | 10.1 | 61 | 79 | 45 | 10.3 | 8.0 | 61 | 10.3 |
height |
2 | 12 | 3 | 9.5 | 4 | 18 | 4 | 10.1 | 3.2 | 1.0 | 2 | 3.2 |
width |
2 | 12 | 3 | 9.5 | 4 | 18 | 4 | 10.1 | 3.2 | 1.0 | 2 | 3.2 |
worker_support |
61 | 79 | 69 | 48 | 10.1 | 61 | 79 | 45 | 10.3 | 8.0 | 61 | 10.3 |
x |
61 | 79 | 31 | 48 | 10.1 | 61 | 31 | 45 | 10.3 | 8.0 | 61 | 10.3 |
y |
61 | 79 | 31 | 48 | 10.1 | 61 | 31 | 45 | 10.3 | 8.0 | 61 | 10.3 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/DOMRect