W3cubDocs

/Web APIs

DOMRectReadOnly

Baseline Widely available

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.

The DOMRectReadOnly interface specifies the standard properties (also used by DOMRect) to define a rectangle whose properties are immutable.

Constructor

DOMRectReadOnly()

Defined to create a new DOMRectReadOnly object.

Instance properties

DOMRectReadOnly.x Read only

Returns the x coordinate of the DOMRectReadOnly's origin.

DOMRectReadOnly.y Read only

Returns the y coordinate of the DOMRectReadOnly's origin.

DOMRectReadOnly.width Read only

Returns the width of the DOMRectReadOnly.

DOMRectReadOnly.height Read only

Returns the height of the DOMRectReadOnly.

DOMRectReadOnly.top Read only

Returns the top coordinate value of the DOMRectReadOnly (usually the same as y).

DOMRectReadOnly.right Read only

Returns the right coordinate value of the DOMRectReadOnly (usually the same as x + width).

DOMRectReadOnly.bottom Read only

Returns the bottom coordinate value of the DOMRectReadOnly (usually the same as y + height).

DOMRectReadOnly.left Read only

Returns the left coordinate value of the DOMRectReadOnly (usually the same as x).

Static methods

DOMRectReadOnly.fromRect()

Creates a new DOMRectReadOnly object with a given location and dimensions.

Instance methods

DOMRectReadOnly.toJSON()

Returns a JSON representation of the DOMRectReadOnly object.

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
DOMRectReadOnly 61 79 62 48 10.1 61 62 45 10.3 8.0 61 10.3
DOMRectReadOnly 612–61 7912–79 3127–313–27 489.5–48 10.14–11 6118–61 3127–314–27 4510.1–45 10.33.2–11 8.01.0–8.0 612–61 10.33.2–11
bottom 2 12 3 9.5 4 18 4 10.1 3.2 1.0 2 3.2
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
left 2 12 3 9.5 4 18 4 10.1 3.2 1.0 2 3.2
right 2 12 3 9.5 4 18 4 10.1 3.2 1.0 2 3.2
toJSON 61 79 62 48 10.1 61 62 45 10.3 8.0 61 10.3
top 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

See also

© 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/DOMRectReadOnly