Firefox Tomorrow

web api interface

DOMRect

View on MDN ↗

Available in 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, getBoundingClientRect() specifies the rectangle that bounds the content of the range using such objects.

It inherits from its parent, DOMRectReadOnly.

Constructor

Instance properties

DOMRect inherits properties from its parent, DOMRectReadOnly. The difference is that they are not read-only anymore.

  • x
    • : The x coordinate of the DOMRect’s origin (typically the top-left corner of the rectangle).
  • y
    • : The y coordinate of the DOMRect’s origin (typically the top-left corner of the rectangle).
  • width
    • : The width of the DOMRect.
  • height
    • : The height of the DOMRect.
  • top
    • : Returns the top coordinate value of the DOMRect (has the same value as y, or y + height if height is negative).
  • right
    • : Returns the right coordinate value of the DOMRect (has the same value as x + width, or x if width is negative).
  • bottom
    • : Returns the bottom coordinate value of the DOMRect (has the same value as y + height, or y if height is negative).
  • left
    • : Returns the left coordinate value of the DOMRect (has the same value as x, or x + width if width is negative).

Static methods

DOMRect may also inherit static methods from its parent, DOMRectReadOnly.

Instance methods

DOMRect may inherit methods from its parent, DOMRectReadOnly.

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.

See also