Web API DOMRect top property Last Updated : 15 Jun, 2023 Comments Improve Suggest changes Like Article Like Report 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 HTML <!DOCTYPE html> <html> <head> <title> DOMRect top property </title> </head> <body> <h1 style="color:green;"> GeeksForGeeks </h1> <h2>DOMRect top property</h2> <button onclick="getDOMRect ();"> Get top </button> <p id='DOMRect'></p> <script type="text/javascript"> function getDOMRect() { let myDOMRect = new DOMRect(0, 0, 100, 100); let rectop = myDOMRect.top; document.getElementById( 'DOMRect').innerHTML = rectop; } </script> </body> </html> Output: Example 2: When the height is negative HTML <!DOCTYPE html> <html> <head> <title> DOMRect top property </title> </head> <body> <h1 style="color:green;"> GeeksForGeeks </h1> <h2>DOMRect top property</h2> <button onclick="getDOMRect ();"> Get top </button> <p id='DOMRect'></p> <script type="text/javascript"> function getDOMRect() { let myDOMRect = new DOMRect(0, 0, 100, -100); let rectop = myDOMRect.top; document.getElementById('DOMRect').innerHTML = rectop; } </script> </body> </html> Output: Supported Browsers: The browsers supported by DOMRect top property are listed below: Google ChromeSafari 10.1FirefoxOpera Comment More infoAdvertise with us Next Article Web API DOMRect top property D DeepakDev Follow Improve Article Tags : JavaScript Web Technologies HTML Web technologies HTML-DOM Web-API +2 More Similar Reads 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 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 width property 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> <tit 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 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 Like