Web API DOMRect fromRect property Last Updated : 15 Jun, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report In Web API there is a DOMRect Interface which has a property fromRect() which creates a DOMRectReadOnly object which has location and dimensions given. Syntax: let domRect = DOMRectReadOnly.fromRect(DOMRect object) Return Value: It returns an instance of DOMRect Example: Using fromRect. HTML <!DOCTYPE html> <html> <head> <title> DOMRect fromRect property </title> </head> <body> <h1 style="color:green;"> GeeksForGeeks </h1> <h2>DOMRect fromRect property</h2> <button onclick="getDOMRect ();"> Get fromRect </button> <p id='DOMRect'></p> <script type="text/javascript"> function getDOMRect() { let myDOMRect = new DOMRect(0, 0, -100, 100); let domRect = DOMRectReadOnly.fromRect(myDOMRect); console.log(domRect); } </script> </body> </html> Output: Supported Browsers: Google Chrome 61Edge 79Safari 10.1Firefox 69Opera 48 Comment More infoAdvertise with us Next Article Web API DOMRect bottom property D DeepakDev Follow Improve Article Tags : Web Tech Web technologies HTML-DOM Web-API Similar Reads Web API DOMRect left property In Web API there is a DOMRect Interface which has a property left that gives us the left of the DOMRect object. It returns the x coordinate value or if the width is negative then it returns x + width. Syntax: let recX = DOMRect.left; Return Type: Double value Example 1: When the width is positive HT 1 min read Web API DOMRect height property In Web API there is a DOMRect Interface that has a property height which gives us the height of the DOMRect object. Syntax: letrecX = DOMRect.height; Return Type: Double value Example: Getting the height of the DOMRect object created. HTML <!DOCTYPE html> <html> <head> <title 1 min read Web API DOMRect bottom property In Web API there is a DOMRect Interface which has a property bottom that gives us the bottom of the DOMRect object. It returns y + height coordinate value or if the height is negative then it returns y. Syntax: let recX = DOMRect.bottom; Return Type : Double value Example 1: When the height is posit 1 min read Web API DOMRect top property In Web API there is a DOMRect Interface which has a property top that gives us the top of the DOMRect object. It returns the y coordinate value or if the height is negative then it returns y + height. Syntax: let recX = DOMRect.top; Return Type: Double value Example 1: When the height is positive HT 1 min read Web API DOMRectReadOnly x property The x property in the DOMRectReadOnly API interface is used to represent the x coordinate. It is a read-only property. Syntax: let recX = DOMRect.x; Return Value: It returns the x coordinate of DOMRectReadOnly API. Example: This example uses DOMRect.x property to get the x-coordinate of the DOMRect 1 min read Web API DOMRectReadOnly y property The y property in the DOMRectReadOnly interface is used to represent the y-coordinate of the DOMRect object. It is a read-only property. Syntax: let recX = DOMRect.y; Return Value: It returns the y-coordinate of the DOMRectReadOnly object. Example: This example uses DOMRect.y property to get the y-c 1 min read Like