Web API DOMRect width property Last Updated : 15 Jun, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report In Web API there is a DOMRectReadOnly Interface which has a property width that gives us the width of the DOMRect object. Syntax: let recX = DOMRect.width; Return Type: Double value Example: Getting the width of the DOMRect object created. HTML <!DOCTYPE html> <html> <head> <title> DOMRect width property </title> </head> <body> <h1 style="color:green;"> GeeksForGeeks </h1> <h2>DOMRect width property</h2> <button onclick="getDOMRect ();"> Get width </button> <p id='DOMRect'></p> <script type="text/javascript"> function getDOMRect() { let myDOMRect = new DOMRect( 0, 0, 100, 100); let recwidth = myDOMRect.width; document.getElementById( 'DOMRect').innerHTML = recwidth; } </script> </body> </html> Output: Supported Browsers: The browsers supported by the DOMRect width property are listed below: Google ChromeSafari 10.1FirefoxOpera 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 right property In Web API there is a DOMRect Interface that has a property right that gives us the right of the DOMRect object. It returns x + width coordinate value or if the width is negative then it returns x. Syntax: let recX = DOMRect.right; Return Type: Double value Example 1: When the width is positive HTML 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 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 DOMRect fromRect property 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 <!DO 1 min read Like